26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
50 #pragma package(smart_init)
63 Graphics::TBitmap* SmallGraphicPtrVal): SpeedTag(SpeedTagVal), TrackType(TrackTypeVal), GraphicPtr(GraphicPtrVal), SmallGraphicPtr(SmallGraphicPtrVal)
65 for(
int x = 0; x < 4; x++)
74 else if(SpeedTagVal == 77)
76 else if(SpeedTagVal == 78)
78 else if(SpeedTagVal == 79)
80 else if(SpeedTagVal == 96)
82 else if(SpeedTagVal == 129)
84 else if(SpeedTagVal == 130)
86 else if(SpeedTagVal == 131)
88 else if(SpeedTagVal == 145)
90 else if(SpeedTagVal == 146)
97 FixedNamedLocationElement(false)
99 for(
int x = 0; x < 4; x++)
110 AnsiString(VLocInput));
123 if((this->
HLoc == RHElement.
HLoc) && (this->VLoc == RHElement.
VLoc) && (this->SpeedTag == RHElement.
SpeedTag))
133 if((this->
HLoc != RHElement.
HLoc) || (this->VLoc != RHElement.
VLoc) || (this->SpeedTag != RHElement.
SpeedTag))
145 Graphics::TBitmap *GraphicOutput = GraphicPtr;
147 if(LocationName ==
"")
192 GraphicOutput = GraphicPtr;
196 Disp->PlotOutput(34, HLoc * 16, VLoc * 16, GraphicOutput);
205 AnsiString LogString =
"TrkEl:-," + AnsiString(ElementID) +
"," + LocationName +
"," + AnsiString(TrainIDOnElement) +
"," +
206 AnsiString(TrainIDOnBridgeTrackPos01) +
"," + AnsiString(TrainIDOnBridgeTrackPos23) +
",EndTrkEl,";
215 if(lower.second < higher.second)
219 else if(lower.second > higher.second)
223 else if(lower.second == higher.second)
225 if(lower.first < higher.first)
238 :
TTrackElement(ElementIn), ELink(ELinkIn), ELinkPos(ELinkPosIn), XLink(XLinkIn), XLinkPos(XLinkPosIn), TrackVectorPosition(TrackVectorPositionIn),
239 CheckCount(9), IsARoute(false), AutoSignals(false), ConsecSignals(false)
243 throw Exception(
"EXNumber failure in TPrefDirElement constructor");
254 AnsiString LogString =
"PthEl:-," + AnsiString(
ELink) +
"," + AnsiString(
ELinkPos) +
"," + AnsiString(
XLink) +
"," + AnsiString(
XLinkPos) +
"," +
282 {2, 4}, {6, 2}, {8, 6}, {4, 8},
283 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
291 else if(
Link[2] == -1)
300 else if(
Link[2] == -1)
308 for(
int x = 0; x < 16; x++)
310 if((Entry == EXArray[x][0]) && (Exit == EXArray[x][1]) || (Entry == EXArray[x][1]) && (Exit == EXArray[x][0]))
440 throw Exception(
"Error in EntryExitNumber 4");
516 throw Exception(
"Error in EntryExitNumber 5");
537 if(!AutoSigsFlag && !ConsecSignalsRoute)
590 throw Exception(
"Error in EntryExitNumber 6");
604 else if(!AutoSigsFlag && ConsecSignalsRoute)
657 throw Exception(
"Error in EntryExitNumber 10");
724 throw Exception(
"Error in EntryExitNumber 11");
797 throw Exception(
"Error in EntryExitNumber 7");
822 throw Exception(
"Error in EntryExitNumber 8");
833 if((ELink > 0) && (ELink < 10) && (ELink != 5))
835 if(!AutoSigsFlag && !ConsecSignalsRoute)
837 else if(!AutoSigsFlag && ConsecSignalsRoute)
844 throw Exception(
"Error in EntryExitNumber 9");
880 TTrack::TActiveLevelCrossing::TActiveLevelCrossing()
905 AnsiString NL =
'\n';
907 RouteFailMessage =
"Unable to set a route:" + NL + NL +
"it may be unreachable; " + NL + NL +
908 "reachable but with too many different directions leading away from the start point - set some points on the route required; " + NL + NL +
909 "blocked by a train, another route or a changing level crossing; " + NL + NL +
910 "or invalid - possibly due to a preferred direction mismatch or a missed signal in a green or blue route.";
917 int InternalLinkCheckArray[9][2] =
918 {{1, 9}, {4, 6}, {7, 3}, {2, 8}, {0, 0}, {8, 2}, {3, 7}, {6, 4}, {9, 1}};
923 for(
int x = 0; x < 9; x++)
924 for(
int y = 0; y < 2; y++)
928 TopPlatAllowed << 1 << 9 << 10 << 30 << 31 << 60 << 61 << 68 << 69 << 77 << 125 << 126 << 129 << 145;
930 BotPlatAllowed << 1 << 7 << 8 << 28 << 29 << 60 << 61 << 68 << 69 << 76 << 125 << 126 << 129 << 145;
931 LeftPlatAllowed << 2 << 12 << 14 << 33 << 35 << 62 << 63 << 70 << 71 << 79 << 127 << 128 << 130 << 146;
932 RightPlatAllowed << 2 << 11 << 13 << 32 << 34 << 62 << 63 << 70 << 71 << 78 << 127 << 128 << 130 << 146;
933 NameAllowed << 1 << 2 << 3 << 4 << 5 << 6 << 20 << 21 << 22 << 23 << 24 << 25 << 26 << 27
934 << 60 << 61 << 62 << 63 << 68 << 69 << 70 << 71 << 80 << 81 << 82 << 83 << 125 << 126 << 127 << 128;
941 {{0, 0}, {-1, -1}, {0, -1}, {1, -1}, {-1, 0}, {0, 0}, {1, 0}, {-1, 1}, {0, 1}, {1, 1}};
943 for(
int x = 0; x < 10; x++)
944 for(
int y = 0; y < 2; y++)
950 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
953 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
954 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
956 {68, 2,
RailGraphics->
bm68dblyellow}, {69, 2,
RailGraphics->
bm69dblyellow}, {70, 2,
RailGraphics->
bm70dblyellow}, {71, 2,
RailGraphics->
bm71dblyellow},
957 {72, 2,
RailGraphics->
bm72dblyellow}, {73, 2,
RailGraphics->
bm73dblyellow}, {74, 2,
RailGraphics->
bm74dblyellow}, {75, 2,
RailGraphics->
bm75dblyellow},
959 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
960 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
963 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
966 for(
int x = 0; x < 40; x++)
972 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
975 {68, 1,
RailGraphics->
bm68yellow}, {69, 1,
RailGraphics->
bm69yellow}, {70, 1,
RailGraphics->
bm70yellow}, {71, 1,
RailGraphics->
bm71yellow},
976 {72, 1,
RailGraphics->
bm72yellow}, {73, 1,
RailGraphics->
bm73yellow}, {74, 1,
RailGraphics->
bm74yellow}, {75, 1,
RailGraphics->
bm75yellow},
978 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
979 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
981 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
982 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
985 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
988 for(
int x = 0; x < 40; x++)
994 {{68, 0,
RailGraphics->
gl68}, {69, 0,
RailGraphics->
gl69}, {70, 0,
RailGraphics->
gl70}, {71, 0,
RailGraphics->
gl71}, {72, 0,
RailGraphics->
gl72},
997 {68, 1,
RailGraphics->
bm68green}, {69, 1,
RailGraphics->
bm69green}, {70, 1,
RailGraphics->
bm70green}, {71, 1,
RailGraphics->
bm71green},
998 {72, 1,
RailGraphics->
bm72green}, {73, 1,
RailGraphics->
bm73green}, {74, 1,
RailGraphics->
bm74green}, {75, 1,
RailGraphics->
bm75green},
1000 {68, 2,
RailGraphics->
bm68green}, {69, 2,
RailGraphics->
bm69green}, {70, 2,
RailGraphics->
bm70green}, {71, 2,
RailGraphics->
bm71green},
1001 {72, 2,
RailGraphics->
bm72green}, {73, 2,
RailGraphics->
bm73green}, {74, 2,
RailGraphics->
bm74green}, {75, 2,
RailGraphics->
bm75green},
1003 {68, 3,
RailGraphics->
bm68green}, {69, 3,
RailGraphics->
bm69green}, {70, 3,
RailGraphics->
bm70green}, {71, 3,
RailGraphics->
bm71green},
1004 {72, 3,
RailGraphics->
bm72green}, {73, 3,
RailGraphics->
bm73green}, {74, 3,
RailGraphics->
bm74green}, {75, 3,
RailGraphics->
bm75green},
1007 {70, 4,
RailGraphics->
gl70}, {71, 4,
RailGraphics->
gl71}, {72, 4,
RailGraphics->
gl72}, {73, 4,
RailGraphics->
bm73}, {74, 4,
RailGraphics->
bm74},
1010 for(
int x = 0; x < 40; x++)
1036 for(
int x = 0; x < 40; x++)
1063 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1064 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1065 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {0, 0, 77}, {-1, 0, 78},
1066 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1067 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, -1, 129},
1068 {0, 0, 129}, {0, -1, 145},
1071 for(
int x = 0; x < 25; x++)
1072 for(
int y = 0; y < 3; y++)
1077 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1078 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {0, 0, 76}, {-1, 0, 77},
1079 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1080 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1081 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1082 {0, 0, 129}, {0, 1, 145},
1085 for(
int x = 0; x < 25; x++)
1086 for(
int y = 0; y < 3; y++)
1091 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1092 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1093 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1094 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1095 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 0, 79}, {-1, 0, 130},
1096 {0, 0, 130}, {-1, 0, 146},
1099 for(
int x = 0; x < 25; x++)
1100 for(
int y = 0; y < 3; y++)
1105 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1106 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1107 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1108 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {0, 0, 78}, {-1, 0, 79},
1109 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {1, 0, 130},
1110 {0, 0, 130}, {1, 0, 146},
1113 for(
int x = 0; x < 25; x++)
1114 for(
int y = 0; y < 3; y++)
1119 {1, 0, 96}, {0, -1, 96}, {0, 1, 96}, {-1, 0, 76},
1120 {1, 0, 76}, {0, -1, 76}, {0, 1, 76}, {-1, 0, 77},
1121 {1, 0, 77}, {0, -1, 77}, {0, 1, 77}, {-1, 0, 78},
1122 {1, 0, 78}, {0, -1, 78}, {0, 1, 78}, {-1, 0, 79},
1123 {1, 0, 79}, {0, -1, 79}, {0, 1, 79}, {0, 1, 129},
1124 {0, -1, 129}, {1, 0, 130},
1125 {-1, 0, 130}, {0, 1, 145},
1126 {0, -1, 145}, {1, 0, 146},
1129 for(
int x = 0; x < 28; x++)
1130 for(
int y = 0; y < 3; y++)
1145 for(
int x = 0; x < 8; x++)
1146 for(
int y = 0; y < 3; y++)
1161 for(
int x = 0; x < 8; x++)
1162 for(
int y = 0; y < 3; y++)
1177 for(
int x = 0; x < 8; x++)
1178 for(
int y = 0; y < 3; y++)
1193 for(
int x = 0; x < 8; x++)
1194 for(
int y = 0; y < 3; y++)
1199 {1, 0, 131}, {0, -1, 131}, {0, 1, 131}};
1201 for(
int x = 0; x < 4; x++)
1202 for(
int y = 0; y < 3; y++)
1206 {0, 1, 2, 5, 6, 3, 4, 9, 10, 7, 8, 13, 14, 11, 12, 15, 16, 17, 19, 18, 22, 23, 20, 21, 26, 27, 24, 25, 30, 31, 28, 29, 34, 35, 32, 33, 38, 39, 36, 37, 42,
1207 43, 40, 41, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 60, 61, 63, 62, 66, 67, 64, 65, 68, 69, 71, 70, 74, 75, 72, 73, 77, 76, 78,
1208 79, 80, 81, 83, 82, 86, 87, 84, 85, 88, 89, 91, 90, 94, 95, 92, 93, 96, 99, 100, 97, 98, 103, 104, 101, 102, 106, 105, 109, 110, 107, 108, 113, 114,
1209 111, 112, 117, 118, 115, 116, 119, 120, 121, 123, 122, 124, 125, 126, 128, 127, 129, 130, 131, 134, 133, 132, 135, 139, 138, 137, 136, 143, 142, 141,
1210 140, 144, 145, 146};
1213 {0, 1, 2, 4, 3, 6, 5, 8, 7, 10, 9, 12, 11, 14, 13, 15, 16, 17, 19, 18, 21, 20, 23, 22, 25, 24, 27, 26, 29, 28, 31, 30, 33, 32, 35, 34, 37, 36, 39, 38, 41,
1214 40, 43, 42, 45, 44, 47, 46, 48, 49, 51, 50, 53, 52, 55, 54, 57, 56, 59, 58, 61, 60, 62, 63, 65, 64, 67, 66, 69, 68, 70, 71, 73, 72, 75, 74, 76, 77, 79,
1215 78, 81, 80, 82, 83, 85, 84, 87, 86, 89, 88, 90, 91, 93, 92, 95, 94, 96, 98, 97, 100, 99, 102, 101, 104, 103, 106, 105, 108, 107, 110, 109, 112, 111,
1216 114, 113, 116, 115, 118, 117, 119, 120, 124, 122, 123, 121, 126, 125, 127, 128, 129, 130, 131, 132, 135, 134, 133, 137, 136, 139, 138, 142, 143, 140,
1217 141, 144, 145, 146};
1220 {0, 2, 1, 4, 6, 3, 5, 14, 12, 13, 11, 7, 9, 8, 10, 15, 16, 17, 19, 18, 25, 27, 24, 26, 21, 23, 20, 22, 35, 33, 34, 32, 28, 30, 29, 31, 41, 43, 40, 42, 37,
1221 39, 36, 38, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 63, 62, 60, 61, 65, 67, 64, 66, 71, 70, 68, 69, 73, 75, 72, 74, 79, 78, 76,
1222 77, 83, 82, 80, 81, 85, 87, 84, 86, 91, 90, 88, 89, 93, 95, 92, 94, 96, 102, 104, 101, 103, 98, 100, 97, 99, 106, 105, 108, 110, 107, 109, 116, 118,
1223 115, 117, 112, 114, 111, 113, 120, 119, 122, 124, 121, 123, 127, 128, 126, 125, 130, 129, 131, 133, 134, 135, 132, 137, 138, 139, 136, 143, 142, 140,
1224 141, 144, 146, 145};
1227 {0, 2, 1, 5, 3, 6, 4, 11, 13, 12, 14, 10, 8, 9, 7, 15, 16, 17, 19, 18, 26, 24, 27, 25, 22, 20, 23, 21, 32, 34, 33, 35, 31, 29, 30, 28, 42, 40, 43, 41, 38,
1228 36, 39, 37, 46, 47, 44, 45, 49, 48, 51, 50, 56, 57, 58, 59, 52, 53, 54, 55, 62, 63, 61, 60, 66, 64, 67, 65, 70, 71, 69, 68, 74, 72, 75, 73, 78, 79, 77,
1229 76, 82, 83, 81, 80, 86, 84, 87, 85, 90, 91, 89, 88, 94, 92, 95, 93, 96, 103, 101, 104, 102, 99, 97, 100, 98, 106, 105, 109, 107, 110, 108, 117, 115,
1230 118, 116, 113, 111, 114, 112, 120, 119, 123, 121, 124, 122, 128, 127, 125, 126, 130, 129, 131, 135, 132, 133, 134, 139, 136, 137, 138, 142, 143, 141,
1231 140, 144, 146, 145};
1251 delete UGMIt->second;
1325 Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
Simple,
1326 Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
Points,
1328 Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
Bridge,
1335 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1336 Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
Parapet,
1349 {4, 6, -1, -1}, {2, 8, -1, -1}, {6, 8, -1, -1}, {4, 8, -1, -1}, {2, 6, -1, -1}, {2, 4, -1, -1},
1350 {4, 6, 4, 2}, {6, 4, 6, 2}, {4, 6, 4, 8}, {6, 4, 6, 8}, {8, 2, 8, 4}, {8, 2, 8, 6}, {2, 8, 2, 4}, {2, 8, 2, 6},
1352 {4, 6, 2, 8}, {1, 9, 3, 7},
1354 {3, 7, -1, -1}, {1, 9, -1, -1}, {7, 6, -1, -1}, {4, 9, -1, -1}, {1, 6, -1, -1}, {4, 3, -1, -1}, {3, 8, -1, -1}, {1, 8, -1, -1}, {2, 9, -1, -1},
1356 {4, 6, 4, 3}, {6, 4, 6, 1}, {4, 6, 4, 9}, {6, 4, 6, 7}, {8, 2, 8, 1}, {8, 2, 8, 3}, {2, 8, 2, 7}, {2, 8, 2, 9}, {9, 1, 9, 2}, {7, 3, 7, 2}, {3, 7, 3, 8
1357 }, {1, 9, 1, 8}, {9, 1, 9, 4}, {7, 3, 7, 6}, {3, 7, 3, 4}, {1, 9, 1, 6},
1360 {1, 9, 2, 8}, {2, 8, 3, 7}, {4, 6, 3, 7}, {1, 9, 4, 6},
1361 {2, 8, 4, 6}, {4, 6, 2, 8}, {3, 7, 1, 9}, {1, 9, 3, 7}, {2, 8, 1, 9}, {2, 8, 3, 7}, {3, 7, 2, 8}, {1, 9, 2, 8}, {4, 6, 3, 7}, {4, 6, 1, 9}, {1, 9, 4, 6
1363 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1
1365 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1
1367 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1368 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1
1370 {4, 6, -1, -1}, {6, 4, -1, -1}, {8, 2, -1, -1}, {2, 8, -1, -1}, {1, 9, -1, -1}, {3, 7, -1, -1}, {7, 3, -1, -1}, {9, 1, -1, -1
1373 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1374 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1375 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1376 {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1}, {-1, -1, -1, -1},
1377 {4, 6, -1, -1}, {4, 6, -1, -1}, {2, 8, -1, -1}, {2, 8, -1, -1},
1378 {4, 6, -1, -1}, {2, 8, -1, -1},
1380 {8, 1, 8, 3}, {4, 3, 4, 9}, {2, 9, 2, 7}, {6, 7, 6, 1}, {9, 4, 9, 2}, {7, 2, 7, 6}, {1, 6, 1, 8}, {3, 8, 3, 4},
1382 {3, 7, -1, -1}, {3, 7, -1, -1}, {1, 9, -1, -1}, {1, 9, -1, -1},
1384 {4, 6, -1, -1}, {2, 8, -1, -1},
1389 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1390 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1391 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1392 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1395 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1396 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1397 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1399 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1400 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1401 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1403 {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn}, {
CrossConn,
CrossConn,
CrossConn,
CrossConn},
1405 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1406 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1407 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1408 {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under}, {
Connection,
Connection,
Under,
Under},
1409 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1410 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1411 {
Connection,
Signal,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet},
1412 {
Signal,
Connection,
NotSet,
NotSet}, {
Signal,
Connection,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet}, {
Connection,
Signal,
NotSet,
NotSet
1414 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1415 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet},
1416 {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet}, {
End,
Connection,
NotSet,
NotSet
1418 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1419 {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet}, {
Gap,
Connection,
NotSet,
NotSet},
1421 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1422 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1423 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1424 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1425 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1426 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1427 {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet}, {
NotSet,
NotSet,
NotSet,
NotSet},
1428 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1432 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1433 {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail}, {
Lead,
Trail,
Lead,
Trail},
1434 {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet}, {
Connection,
Connection,
NotSet,
NotSet},
1440 for(
int x = 0; x < 17; x++)
1442 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1444 FixedTrackPiece[17] =
TFixedTrackPiece(17, TrackTypeArray[17], Links[17], Configs[17], 0, 0);
1448 FixedTrackPiece[x] =
TFixedTrackPiece(x, TrackTypeArray[x], Links[x], Configs[x], TrackImageArray[x], SmallTrackImageArray[x]);
1454 ExistingGraphicLoaded(false), Width(16), Height(16)
1466 ExistingGraphicLoaded(false), Width(WidthIn), Height(HeightIn)
1504 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalScreenGraphic()");
1508 throw Exception(
"Overlay not 16x16 in TGraphicElement::LoadOriginalScreenGraphic()");
1512 throw Exception(
"Source not set in TGraphicElement::LoadOriginalScreenGraphic()");
1516 throw Exception(
"ExistingGraphicLoaded in TGraphicElement::LoadOriginalScreenGraphic()");
1539 AnsiString(VOffset) +
"," + AnsiString(WidthIn) +
"," + AnsiString(HeightIn));
1542 throw Exception(
"Overlay not loaded in TGraphicElement::LoadOriginalExistingGraphic()");
1546 throw Exception(
"Source not set in TGraphicElement::LoadOriginalExistingGraphic()");
1550 throw Exception(
"ScreenGraphicLoaded in TGraphicElement::LoadOriginalExistingGraphic()");
1584 throw Exception(
"Overlay not loaded in TGraphicElement::PlotOverlay()");
1605 throw Exception(
"Original not loaded in TGraphicElement::PlotOriginal()");
1619 bool TrackPresent =
false;
1633 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1636 TrackPresent =
true;
1640 return !TrackPresent;
1648 bool TrackPresent =
false;
1657 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
1660 TrackPresent =
true;
1665 return !TrackPresent;
1670 void TTrack::EraseTrackElement(
int Caller,
int HLocInput,
int VLocInput,
int &ErasedTrackVectorPosition,
bool &TrackEraseSuccessfulFlag,
bool InternalChecks)
1673 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
1674 TrackEraseSuccessfulFlag =
false;
1679 ErasedTrackVectorPosition = -1;
1680 AnsiString SName =
"", ErrorString;
1682 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
1688 TrackMapKeyPair.first = HLocInput;
1689 TrackMapKeyPair.second = VLocInput;
1690 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
1701 if(ErrorString !=
"")
1703 throw Exception(ErrorString +
" for EraseTrackElement 1");
1726 ErasedTrackVectorPosition = VecPos;
1727 TrackEraseSuccessfulFlag =
true;
1734 unsigned int VecPos;
1735 InactiveTrackMapKeyPair.first = HLocInput;
1736 InactiveTrackMapKeyPair.second = VLocInput;
1741 VecPos = InactiveTrack2MultiMapIterator->second;
1746 if(ErrorString !=
"")
1748 throw Exception(ErrorString +
" for EraseTrackElement 2A");
1758 TrackEraseSuccessfulFlag =
true;
1778 VecPos = InactiveTrack2MultiMapIterator->second;
1783 if(ErrorString !=
"")
1785 throw Exception(ErrorString +
" for EraseTrackElement 2B");
1807 if(TrackEraseSuccessfulFlag)
1829 AnsiString(HLocInput) +
"," + AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
1830 bool PlatAllowedFlag =
false;
1832 TrackLinkingRequiredFlag =
false;
1844 LocationNameEntry.first =
"";
1853 TempTrackElement.
HLoc = HLocInput;
1854 TempTrackElement.
VLoc = VLocInput;
1880 else if(Aspect == 1)
1882 else if(Aspect == 2)
1884 else if(Aspect == 3)
1890 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
1893 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
1895 if(InactiveFoundFlag)
1898 NonStationOrLevelCrossingPresent =
true;
1900 NonStationOrLevelCrossingPresent =
true;
1902 PlatformPresent =
true;
1913 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
1920 PlatAllowedFlag =
true;
1924 PlatAllowedFlag =
true;
1928 PlatAllowedFlag =
true;
1932 PlatAllowedFlag =
true;
1936 TrackLinkingRequiredFlag =
true;
1963 if((FoundFlag && (
NameAllowed.Contains(
TrackVector.at(VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
1964 (!FoundFlag && !InactiveFoundFlag))
1967 TrackLinkingRequiredFlag =
true;
2000 TrackLinkingRequiredFlag =
true;
2012 else if(FoundFlag || InactiveFoundFlag)
2032 bool BothPointFillets =
true;
2046 TrackLinkingRequiredFlag =
true;
2059 bool InternalChecks)
2067 AnsiString(VLocInput) +
"," + AnsiString((
short)InternalChecks));
2068 bool PlatAllowedFlag =
false;
2070 TrackLinkingRequiredFlag =
false;
2082 LocationNameEntry.first =
"";
2089 TempTrackElement.
HLoc = HLocInput;
2090 TempTrackElement.
VLoc = VLocInput;
2091 for(
int x = 0; x < 4; x++)
2095 TempTrackElement.
Conn[x] = -1;
2099 bool FoundFlag =
false, InactiveFoundFlag =
false, NonStationOrLevelCrossingPresent =
false, PlatformPresent =
false;
2110 int InactiveSpeedTag1 = 0, InactiveSpeedTag2 = 0;
2112 if(InactiveFoundFlag)
2115 NonStationOrLevelCrossingPresent =
true;
2117 NonStationOrLevelCrossingPresent =
true;
2119 PlatformPresent =
true;
2130 if(InactiveFoundFlag && ((TempTrackElement.
SpeedTag == InactiveSpeedTag1) || (TempTrackElement.
SpeedTag == InactiveSpeedTag2)))
2137 PlatAllowedFlag =
true;
2141 PlatAllowedFlag =
true;
2145 PlatAllowedFlag =
true;
2149 PlatAllowedFlag =
true;
2153 TrackLinkingRequiredFlag =
true;
2183 if((FoundFlag && (
NameAllowed.Contains(
TrackVector.at(VecPos).SpeedTag)) && !PlatformPresent && !InactiveFoundFlag) ||
2184 (!FoundFlag && !InactiveFoundFlag))
2187 TrackLinkingRequiredFlag =
true;
2223 TrackLinkingRequiredFlag =
true;
2235 else if(FoundFlag || InactiveFoundFlag)
2255 bool BothPointFillets =
true;
2269 TrackLinkingRequiredFlag =
true;
2297 ShowMessage(
"Gaps must be set before track can be validated");
2306 throw Exception(
"Error, gaps unset when TryToConnectTrack called");
2317 if(!
LinkTrack(1, LocError, HLoc, VLoc,
false))
2335 ShowMessage(
"Error in RepositionAndMapTrack during TryToConnectTrack. Railway file is corrupt, further use may cause a system crash");
2342 if(!
LinkTrack(2, LocError, HLoc, VLoc,
true))
2367 std::pair<AnsiString, char>TempMapPair;
2375 TempMapPair.second =
'x';
2388 int NewHLoc, NewVLoc;
2389 bool ConnectionFoundFlag, LinkFoundFlag;
2391 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2393 for(
unsigned int y = 0; y < 4; y++)
2405 ConnectionFoundFlag =
false;
2406 for(
unsigned int z = 0; z <
TrackVector.size(); z++)
2412 ConnectionFoundFlag =
true;
2414 LinkFoundFlag =
false;
2415 for(
unsigned int a = 0; a < 4; a++)
2419 LinkFoundFlag =
true;
2434 if(!ConnectionFoundFlag)
2507 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2522 bool UnsetGaps =
false;
2529 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
2533 for(
unsigned int y = 0; y < 4; y++)
2545 for(
unsigned int y = 0; y < 4; y++)
2555 for(
unsigned int y = 1; y < 4; y++)
2564 for(
unsigned int y = 0; y < 4; y++)
2577 for(
unsigned int y = 0; y < 4; y++)
2604 int NumberOfActiveElements = 0;
2606 GraphicsFollow =
false;
2610 if(MarkerString[MarkerString.Length()] ==
'1')
2612 GraphicsFollow =
true;
2614 for(
int x = 0; x < NumberOfActiveElements; x++)
2620 TrackElement.
HLoc = TempInt;
2622 TrackElement.
VLoc = TempInt;
2628 TrackElement.
Conn[0] = TempInt;
2648 if((TempInt != -1) && (TempInt < 10))
2654 if((TempInt != -1) && (TempInt < 10))
2667 if(Marker[1] ==
'3')
2671 else if(Marker[1] ==
'2')
2675 else if(Marker[1] ==
'G')
2687 int NumberOfInactiveElements = 0;
2691 for(
int x = 0; x < NumberOfInactiveElements; x++)
2697 TrackElement.
HLoc = TempInt;
2699 TrackElement.
VLoc = TempInt;
2705 bool LocError =
false;
2734 for(
int x = 0; x < NumberOfGraphics; x++)
2745 bool FileError =
false;
2747 for(
int x = 0; x < NumberOfGraphics; x++)
2760 UGME.second =
new TPicture;
2761 UGME.second->LoadFromFile(
UGME.first);
2764 throw Exception(
"Map Insertion Error 2 - UserGraphicMap insertion failure for " + UGI.
FileName);
2771 catch(
const EInvalidGraphic &e)
2780 delete UGMIt->second;
2785 catch(
const Exception &e)
2794 delete UGMIt->second;
2802 bool FoundInMap =
false;
2821 UGME.second =
new TPicture;
2822 UGME.second->LoadFromFile(
UGME.first);
2825 throw Exception(
"Map Insertion Error 3 - UserGraphicMap insertion failure for " + UGI.
FileName);
2832 catch(
const EInvalidGraphic &e)
2841 delete UGMIt->second;
2846 catch(
const Exception &e)
2855 delete UGMIt->second;
2880 VecFile <<
"**Active elements**1" <<
'\0' <<
'\n';
2884 VecFile <<
"**Active elements**" <<
'\0' <<
'\n';
2886 for(
unsigned int x = 0; x < (
TrackVector.size()); x++)
2889 VecFile << x <<
'\n';
2890 VecFile << TrackElement.
SpeedTag <<
'\n';
2891 VecFile << TrackElement.
HLoc <<
'\n';
2892 VecFile << TrackElement.
VLoc <<
'\n';
2896 VecFile << TrackElement.
Conn[0] <<
'\n';
2900 VecFile << TrackElement.
Attribute <<
'\n';
2905 VecFile << int(1) <<
'\n';
2907 VecFile << int(0) <<
'\n';
2909 VecFile << TrackElement.
Length01 <<
'\n';
2910 VecFile << TrackElement.
Length23 <<
'\n';
2913 VecFile << TrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
2920 VecFile <<
"3*****" <<
'\0' <<
'\n';
2924 VecFile <<
"2*****" <<
'\0' <<
'\n';
2928 VecFile <<
"G*****" <<
'\0' <<
'\n';
2932 VecFile <<
"4*****" <<
'\0' <<
'\n';
2937 VecFile <<
"******" <<
'\0' <<
'\n';
2942 VecFile <<
"**Inactive elements**" <<
'\0' <<
'\n';
2946 VecFile << x <<
'\n';
2947 VecFile << InactiveTrackElement.
SpeedTag <<
'\n';
2948 VecFile << InactiveTrackElement.
HLoc <<
'\n';
2949 VecFile << InactiveTrackElement.
VLoc <<
'\n';
2950 VecFile << InactiveTrackElement.
LocationName.c_str() <<
'\0' <<
'\n';
2951 VecFile <<
"******" <<
'\0' <<
'\n';
2966 GraphicsFollow =
false;
2968 if((NumberOfActiveElements < 0) || (NumberOfActiveElements > 1000000))
2974 AnsiString MarkerString;
2981 if(MarkerString[MarkerString.Length()] ==
'1')
2983 GraphicsFollow =
true;
2985 for(
int x = 0; x < NumberOfActiveElements; x++)
2993 int SpeedTag = TempInt;
3000 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3006 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3011 if((SpeedTag > 87) && (SpeedTag < 96))
3014 if((TempInt < -1) || (TempInt > 3))
3020 if((TempInt < -1) || (TempInt > 999999))
3026 if(((SpeedTag >= 7) && (SpeedTag <= 14)) || ((SpeedTag >= 28) && (SpeedTag <= 43)) || ((SpeedTag >= 132) && (SpeedTag <= 139)) ||
3027 ((SpeedTag >= 68) && (SpeedTag <= 75)))
3030 if((TempInt < -1) || (TempInt > 5))
3036 if((SpeedTag >= 68) && (SpeedTag <= 75))
3039 if((TempInt != 0) && (TempInt != 1))
3046 if((TempInt < -1) || (TempInt > 999999))
3052 if((TempInt < -1) || (TempInt > 999999))
3058 if((TempInt < -1) || (TempInt > 999999))
3064 if((TempInt < -1) || (TempInt > 999999))
3085 int NumberOfInactiveElements = 0;
3088 if(NumberOfInactiveElements < 0)
3098 for(
int x = 0; x < NumberOfInactiveElements; x++)
3112 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3118 if(((TempInt > 999999) || (TempInt < -1000001)) && (TempInt != -2000000000))
3145 if((NumberOfGraphics < 0) || (NumberOfGraphics > 100000))
3151 AnsiString FileName =
"", TempStr =
"";
3153 for(
int x = 0; x < NumberOfGraphics; x++)
3155 TPicture *TempPicture =
new TPicture;
3164 TempPicture->LoadFromFile(GraphicsPath +
"\\" + FileName);
3177 catch(
const EInvalidGraphic &e)
3182 for(
int y = x + 1; y < NumberOfGraphics; y++)
3188 ShowMessage(FileName +
3189 " has an incorrect file format, user graphics can't be loaded. Ensure that all user graphic files are valid with extension .bmp, .gif, .jpg, or .png");
3194 catch(
const Exception &e)
3199 for(
int y = x + 1; y < NumberOfGraphics; y++)
3205 ShowMessage(
"Unable to load user graphic files, ensure that " + FileName +
3206 " exists in the 'Graphics' folder and that it is has extension .bmp, .gif, .jpg, or .png.");
3224 for(
int x = 0; x < VecSize; x++)
3247 for(
int x = 0; x < VecSize; x++)
3269 for(
int x = 0; x < VecSize; x++)
3323 for(
int x = 0; x < VecSize; x++)
3380 PlotPoints(5, Next, Disp, BothPointFilletsAndBasicLCs);
3391 if(BothPointFilletsAndBasicLCs)
3466 Bitmap->Canvas->CopyMode = cmSrcCopy;
3468 Graphics::TBitmap *GraphicOutput;
3639 for(
int x = 0; x < 40; x++)
3658 Graphics::TBitmap *GraphicPtr;
3667 Graphics::TBitmap* SignalPlatformGraphic;
3700 if(OldTransparentColour !=
clB5G5R5)
3723 Bitmap->Canvas->CopyMode = cmSrcCopy;
3751 Bitmap->Canvas->CopyMode = cmSrcCopy;
3753 Graphics::TBitmap *GraphicOutput;
3763 if(BaseElement == 1)
3851 for(
int x = 0; x < 40; x++)
3870 Graphics::TBitmap *GraphicPtr;
3879 Graphics::TBitmap* SignalPlatformGraphic;
3940 for(
int x = 0; x < 40; x++)
3948 Graphics::TBitmap* SignalPlatformGraphic;
3969 if(OldTransparentColour !=
clB5G5R5)
3983 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4053 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4067 ShowMessage(
"Error - gap connected to a non-gap. Railway file is corrupt, further use may cause a system crash");
4092 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4117 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4147 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4181 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4217 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4232 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4262 for(TrackMapPtr =
TrackMap.begin(); TrackMapPtr !=
TrackMap.end(); TrackMapPtr++)
4269 throw Exception(
"Error - Map & Vector different sizes");
4271 unsigned int NonZeroCount = 0;
4273 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4280 throw Exception(
"Error - NewVector & NonZero TrackVector different sizes");
4287 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4291 TrackMapEntry.first = TrackMapKeyPair;
4292 TrackMapEntry.second = x;
4293 if(!(
TrackMap.insert(TrackMapEntry).second))
4295 throw Exception(
"Error - map insertion failure, TrackVector in error");
4299 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4301 for(
unsigned int y = 0; y < 4; y++)
4326 THVPair GapMapKeyPair, GapMapValuePair;
4329 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4335 GapMapEntry.first = GapMapKeyPair;
4338 throw Exception(
"Error - Gap connection == -1 Can't build GapMap");
4342 GapMapEntry.second = GapMapValuePair;
4345 GapMap.insert(GapMapEntry);
4358 bool CheckForLinks =
false;
4360 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4370 "Footbridge or underpass connection error. Each end must connect to a platform, concourse or other footbridge or underpass, and they can't connect to each other");
4378 for(
unsigned int y = 0; y < 4; y++)
4380 CheckForLinks =
false;
4392 bool ConnectionFoundFlag;
4396 ShowMessage(
"Can't have a track element adjacent to a continuation exit");
4402 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4409 if(ConnectionFoundFlag)
4413 bool LinkFoundFlag =
false;
4416 ShowMessage(
"Can't have an exit signal next to a level crossing - it can cause the train to foul the crossing in some circumstances");
4422 ShowMessage(
"Can't have points, crossover or signal next to buffers - need room for a train without fouling");
4428 ShowMessage(
"Can't have points, crossover, bridge or signal next to a continuation - it can cause route setting problems");
4436 ShowMessage(
"Can't have two same-direction signals adjacent to each other as there is no room for a train between them");
4442 ShowMessage(
"Signal facing a bridge - routes can't be truncated to this or other such signals.\n\nThis restriction can be removed or reinstated by pressing\nCTRL ALT 5. When removed this message will not be shown again.");
4449 ShowMessage(
"Can't have two level crossings adjacent to each other on the same track");
4452 CheckForLinks =
true;
4455 for(
unsigned int a = 0; a < 4; a++)
4464 LinkFoundFlag =
true;
4477 throw Exception(
"Error in final track linkage - invalid link");
4491 throw Exception(
"Error in final track linkage - connection not found");
4503 bool ConnErrorFlag =
false;
4505 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4508 ConnErrorFlag =
true;
4510 ConnErrorFlag =
true;
4512 ConnErrorFlag =
true;
4514 ConnErrorFlag =
true;
4517 if(
TrackVector.at(x).ActiveTrackElementName ==
"")
4519 if((
TrackVector.at(x).StationEntryStopLinkPos1 != -1) || (
TrackVector.at(x).StationEntryStopLinkPos2 != -1))
4521 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
4530 throw Exception(
"ConnError in LinkTrack - Final");
4534 throw Exception(
"ConnError in LinkTrack - Precheck");
4538 bool CLkErrorFlag =
false;
4540 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4543 CLkErrorFlag =
true;
4545 CLkErrorFlag =
true;
4547 CLkErrorFlag =
true;
4549 CLkErrorFlag =
true;
4556 throw Exception(
"CLkError in LinkTrack - Final");
4560 throw Exception(
"CLkError in LinkTrack - Precheck");
4565 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4588 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4603 for(
unsigned int y = 0; y < 4; y++)
4616 bool ConnectionFoundFlag;
4622 throw Exception(
"Error in final track linkage - continuation adjacent to another element");
4629 if(ConnectionFoundFlag)
4632 bool LinkFoundFlag =
false;
4689 for(
unsigned int a = 0; a < 4; a++)
4698 LinkFoundFlag =
true;
4706 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - invalid link");
4716 throw Exception(
"Error in final track linkage in LinkTrackNoMessages - connection not found");
4728 bool ConnErrorFlag =
false;
4730 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4733 ConnErrorFlag =
true;
4735 ConnErrorFlag =
true;
4737 ConnErrorFlag =
true;
4739 ConnErrorFlag =
true;
4742 if(
TrackVector.at(x).ActiveTrackElementName ==
"")
4744 if((
TrackVector.at(x).StationEntryStopLinkPos1 != -1) || (
TrackVector.at(x).StationEntryStopLinkPos2 != -1))
4746 throw Exception(
"Error, StationEntryStopLinkPos not -1 for unnamed element at TrackVectorPosition = " + AnsiString(x));
4755 throw Exception(
"ConnError in LinkTrack - Final");
4759 throw Exception(
"ConnError in LinkTrack - Precheck");
4763 bool CLkErrorFlag =
false;
4765 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4768 CLkErrorFlag =
true;
4770 CLkErrorFlag =
true;
4772 CLkErrorFlag =
true;
4774 CLkErrorFlag =
true;
4781 throw Exception(
"CLkError in LinkTrack - Final");
4785 throw Exception(
"CLkError in LinkTrack - Precheck");
4790 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4813 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4831 for(
unsigned int y = 0; y < 4; y++)
4844 bool ConnectionFoundFlag =
false;
4846 if(ConnectionFoundFlag)
4850 bool LinkFoundFlag =
false;
4870 for(
unsigned int a = 0; a < 4; a++)
4879 LinkFoundFlag =
true;
4899 bool ConnErrorFlag =
false;
4901 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4904 ConnErrorFlag =
true;
4906 ConnErrorFlag =
true;
4908 ConnErrorFlag =
true;
4910 ConnErrorFlag =
true;
4918 bool CLkErrorFlag =
false;
4920 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
4923 CLkErrorFlag =
true;
4925 CLkErrorFlag =
true;
4927 CLkErrorFlag =
true;
4929 CLkErrorFlag =
true;
4946 int Position1, Position2;
4952 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
4954 int HLoc1 = GapMapPtr->first.first;
4955 int VLoc1 = GapMapPtr->first.second;
4956 int HLoc2 = GapMapPtr->second.first;
4957 int VLoc2 = GapMapPtr->second.second;
4960 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
4964 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
4968 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
4972 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
4990 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
4991 THVPair TrackMapKeyPair, InactiveTrackMapKeyPair;
5001 bool FoundFlag =
false;
5013 InactiveTrackMapKeyPair.first = TrackElement.
HLoc;
5014 InactiveTrackMapKeyPair.second = TrackElement.
VLoc;
5015 InactiveTrackMapEntry.first = InactiveTrackMapKeyPair;
5036 bool FoundFlag =
false;
5049 TrackMapKeyPair.first = TrackElement.
HLoc;
5050 TrackMapKeyPair.second = TrackElement.
VLoc;
5051 TrackMapEntry.first = TrackMapKeyPair;
5056 LocationNameEntry.second = -(int)(
TrackVector.size());
5088 TrackMapKeyPair.first = HLoc;
5089 TrackMapKeyPair.second = VLoc;
5090 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5100 return TrackMapPtr->second;
5113 TrackMapKeyPair.first = HLoc;
5114 TrackMapKeyPair.second = VLoc;
5115 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5118 AnsiString Message =
"Element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5119 throw Exception(Message);
5134 THVPair InactiveTrackMapKeyPair;
5137 InactiveTrackMapKeyPair.first = HLoc;
5138 InactiveTrackMapKeyPair.second = VLoc;
5142 AnsiString Message =
"Inactive element not found at HLoc " + AnsiString(HLoc) +
" and VLoc " + AnsiString(VLoc);
5143 throw Exception(Message);
5157 bool Present =
true;
5161 TrackMapKeyPair.first = HLoc;
5162 TrackMapKeyPair.second = VLoc;
5163 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
5178 bool Present =
true;
5179 THVPair InactiveTrackMapKeyPair;
5182 InactiveTrackMapKeyPair.first = HLoc;
5183 InactiveTrackMapKeyPair.second = VLoc;
5201 THVPair InactiveTrackMapKeyPair;
5206 InactiveTrackMapKeyPair.first = HLoc;
5207 InactiveTrackMapKeyPair.second = VLoc;
5216 if(InactiveTrackRange.first == InactiveTrackRange.second)
5225 RetPair.first = InactiveTrackRange.first->second;
5226 RetPair.second = (--InactiveTrackRange.second)->second;
5239 AnsiString(DivergingPosition));
5250 if(((SpeedTag1 == 7) && (SpeedTag2 == 10)) ||
5251 ((SpeedTag1 == 10) && (SpeedTag2 == 7)) || ((SpeedTag1 == 8) && (SpeedTag2 == 9)) || ((SpeedTag1 == 9) && (SpeedTag2 == 8)) ||
5252 ((SpeedTag1 == 11) && (SpeedTag2 == 14)) ||
5253 ((SpeedTag1 == 14) && (SpeedTag2 == 11)) || ((SpeedTag1 == 12) && (SpeedTag2 == 13)) || ((SpeedTag1 == 13) && (SpeedTag2 == 12)) ||
5254 ((SpeedTag1 == 28) && (SpeedTag2 == 31)) ||
5255 ((SpeedTag1 == 31) && (SpeedTag2 == 28)) || ((SpeedTag1 == 29) && (SpeedTag2 == 30)) || ((SpeedTag1 == 30) && (SpeedTag2 == 29)) ||
5256 ((SpeedTag1 == 32) && (SpeedTag2 == 35)) ||
5257 ((SpeedTag1 == 35) && (SpeedTag2 == 32)) || ((SpeedTag1 == 33) && (SpeedTag2 == 34)) || ((SpeedTag1 == 34) && (SpeedTag2 == 33)) ||
5258 ((SpeedTag1 == 36) && (SpeedTag2 == 39)) ||
5259 ((SpeedTag1 == 39) && (SpeedTag2 == 36)) || ((SpeedTag1 == 37) && (SpeedTag2 == 38)) || ((SpeedTag1 == 38) && (SpeedTag2 == 37)) ||
5260 ((SpeedTag1 == 40) && (SpeedTag2 == 43)) ||
5261 ((SpeedTag1 == 43) && (SpeedTag2 == 40)) || ((SpeedTag1 == 41) && (SpeedTag2 == 42)) || ((SpeedTag1 == 42) && (SpeedTag2 == 41)))
5295 throw Exception(
"Error, Wrong track type in PlotGap");
5297 if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] > -1))
5301 else if((TrackElement.
SpeedTag == 88) && (TrackElement.
Conn[0] == -1))
5305 if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] > -1))
5309 else if((TrackElement.
SpeedTag == 89) && (TrackElement.
Conn[0] == -1))
5313 if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] > -1))
5317 else if((TrackElement.
SpeedTag == 90) && (TrackElement.
Conn[0] == -1))
5321 if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] > -1))
5325 else if((TrackElement.
SpeedTag == 91) && (TrackElement.
Conn[0] == -1))
5329 if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] > -1))
5333 else if((TrackElement.
SpeedTag == 92) && (TrackElement.
Conn[0] == -1))
5337 if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] > -1))
5341 else if((TrackElement.
SpeedTag == 93) && (TrackElement.
Conn[0] == -1))
5345 if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] > -1))
5349 else if((TrackElement.
SpeedTag == 94) && (TrackElement.
Conn[0] == -1))
5353 if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] > -1))
5357 else if((TrackElement.
SpeedTag == 95) && (TrackElement.
Conn[0] == -1))
5371 throw Exception(
"Error, Wrong track type in PlotPoints");
5382 else if(TrackElement.
SpeedTag < 132)
5400 else if(TrackElement.
SpeedTag < 132)
5432 throw Exception(
"Error, Wrong track type in PlotSignal");
5434 for(
int x = 0; x < 40; x++)
5505 for(
int x = 0; x < 40; x++)
5512 Graphics::TBitmap* SignalPlatformGraphic;
5599 while(
IsLCAtHV(0, HLoc, (VLoc + UpStep)))
5607 while(
IsLCAtHV(1, HLoc, (VLoc + DownStep)))
5615 while(
IsLCAtHV(2, (HLoc + LeftStep), VLoc))
5623 while(
IsLCAtHV(3, (HLoc + RightStep), VLoc))
5639 while(
IsLCAtHV(51, HLoc, (VLoc + UpStep)))
5647 while(
IsLCAtHV(52, HLoc, (VLoc + DownStep)))
5655 while(
IsLCAtHV(53, (HLoc + LeftStep), VLoc))
5663 while(
IsLCAtHV(54, (HLoc + RightStep), VLoc))
5695 while(
IsLCAtHV(55, HLoc, (VLoc + UpStep)))
5707 while(
IsLCAtHV(56, HLoc, (VLoc + DownStep)))
5719 while(
IsLCAtHV(57, (HLoc + LeftStep), VLoc))
5731 while(
IsLCAtHV(58, (HLoc + RightStep), VLoc))
5773 throw Exception(
"Error, Wrong track type in PlotAndLowerLevelCrossingBarriers");
5775 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
5777 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndLowerLevelCrossingBarriers");
5780 if(BaseElementSpeedTag == 1)
5784 while(
IsLCAtHV(5, HLoc, (VLoc + UpStep)))
5791 while(
IsLCAtHV(6, HLoc, (VLoc + DownStep)))
5799 Graphics::TBitmap *RouteGraphic;
5801 if(ConsecSignals == 1)
5805 else if(ConsecSignals == 0)
5811 RouteGraphic = BaseGraphic;
5818 if(UpStep == DownStep)
5821 Disp->
PlotOutput(133, HLoc * 16, VLoc * 16, RouteGraphic);
5831 else if((DownStep - UpStep) == 1)
5836 Disp->
PlotOutput(136, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
5846 Disp->
PlotOutput(139, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
5859 Disp->
PlotOutput(196, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
5869 Disp->
PlotOutput(199, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
5885 Disp->
PlotOutput(142, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
5895 Disp->
PlotOutput(145, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
5905 else if(DownStep == 0)
5908 Disp->
PlotOutput(202, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
5918 Disp->
PlotOutput(205, HLoc * 16, (VLoc + DownStep) * 16, RouteGraphic);
5931 Disp->
PlotOutput(208, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
5941 Disp->
PlotOutput(211, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
5951 for(
int x = (UpStep + 1); x < DownStep; x++)
5955 Disp->
PlotOutput(148, HLoc * 16, (VLoc + x) * 16, RouteGraphic);
5957 Disp->
PlotOutput(213, HLoc * 16, (VLoc + x) * 16, BaseGraphic);
5977 while(
IsLCAtHV(7, (HLoc + LStep), VLoc))
5984 while(
IsLCAtHV(8, (HLoc + RStep), VLoc))
5990 Graphics::TBitmap *RouteGraphic;
5992 if(ConsecSignals == 1)
5996 else if(ConsecSignals == 0)
6002 RouteGraphic = BaseGraphic;
6011 Disp->
PlotOutput(151, HLoc * 16, VLoc * 16, RouteGraphic);
6021 else if((RStep - LStep) == 1)
6026 Disp->
PlotOutput(154, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6036 Disp->
PlotOutput(157, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6049 Disp->
PlotOutput(215, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6059 Disp->
PlotOutput(218, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6075 Disp->
PlotOutput(160, (HLoc + LStep) * 16, VLoc * 16, RouteGraphic);
6085 Disp->
PlotOutput(163, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6098 Disp->
PlotOutput(221, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6108 Disp->
PlotOutput(224, (HLoc + RStep) * 16, VLoc * 16, RouteGraphic);
6121 Disp->
PlotOutput(227, (HLoc + LStep) * 16, VLoc * 16, BaseGraphic);
6131 Disp->
PlotOutput(230, (HLoc + RStep) * 16, VLoc * 16, BaseGraphic);
6141 for(
int x = (LStep + 1); x < RStep; x++)
6146 Disp->
PlotOutput(166, (HLoc + x) * 16, VLoc * 16, RouteGraphic);
6150 Disp->
PlotOutput(232, (HLoc + x) * 16, VLoc * 16, BaseGraphic);
6174 AnsiString(HLoc) +
"," + AnsiString(VLoc));
6177 throw Exception(
"Error, Wrong track type in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
6179 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6181 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainLoweredLinkedLevelCrossingBarriersAndSetMarkers");
6184 if(BaseElementSpeedTag == 1)
6188 while(
IsLCAtHV(30, HLoc, (VLoc + UpStep)))
6195 while(
IsLCAtHV(31, HLoc, (VLoc + DownStep)))
6201 if(UpStep == DownStep)
6212 else if((DownStep - UpStep) == 1)
6231 for(
int x = (UpStep + 1); x < DownStep; x++)
6240 for(
int x = (UpStep + 1); x < DownStep; x++)
6247 for(
int x = UpStep; x <= DownStep; x++)
6260 while(
IsLCAtHV(32, (HLoc + LStep), VLoc))
6267 while(
IsLCAtHV(33, (HLoc + RStep), VLoc))
6284 else if((RStep - LStep) == 1)
6303 for(
int x = (LStep + 1); x < RStep; x++)
6312 for(
int x = (LStep + 1); x < RStep; x++)
6319 for(
int x = LStep; x <= RStep; x++)
6338 throw Exception(
"Error, Wrong track type in PlotAndRaiseLevelCrossingBarriers");
6340 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6342 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotAndRaiseLevelCrossingBarriers");
6345 if(BaseElementSpeedTag == 1)
6349 while(
IsLCAtHV(10, HLoc, (VLoc + UpStep)))
6356 while(
IsLCAtHV(11, HLoc, (VLoc + DownStep)))
6362 for(
int x = UpStep; x < (DownStep + 1); x++)
6377 while(
IsLCAtHV(12, (HLoc + LStep), VLoc))
6384 while(
IsLCAtHV(13, (HLoc + RStep), VLoc))
6390 for(
int x = LStep; x < (RStep + 1); x++)
6409 AnsiString(HLoc) +
"," + AnsiString(VLoc));
6412 throw Exception(
"Error, Wrong track type in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
6414 if((BaseElementSpeedTag != 1) && (BaseElementSpeedTag != 2))
6416 throw Exception(
"Error, Wrong BaseElementSpeedTag value in PlotPlainRaisedLinkedLevelCrossingBarriersAndSetMarkers");
6421 if(BaseElementSpeedTag == 1)
6425 while(
IsLCAtHV(35, HLoc, (VLoc + UpStep)))
6432 while(
IsLCAtHV(36, HLoc, (VLoc + DownStep)))
6438 for(
int x = UpStep; x <= DownStep; x++)
6452 while(
IsLCAtHV(37, (HLoc + LStep), VLoc))
6459 while(
IsLCAtHV(38, (HLoc + RStep), VLoc))
6465 for(
int x = LStep; x <= RStep; x++)
6481 Graphics::TBitmap *RouteGraphic;
6484 if(BaseElementSpeedTag == 1)
6486 if(ConsecSignals == 1)
6490 else if(ConsecSignals == 0)
6496 RouteGraphic = BaseGraphic;
6500 RouteGraphic = BaseGraphic;
6505 if(ConsecSignals == 1)
6509 else if(ConsecSignals == 0)
6515 RouteGraphic = BaseGraphic;
6518 RouteGraphic = BaseGraphic;
6522 while(
IsLCAtHV(14, HLoc, (VLoc + UpStep)))
6526 Disp->
PlotOutput(175, HLoc * 16, (VLoc + UpStep) * 16, RouteGraphic);
6528 Disp->
PlotOutput(234, HLoc * 16, (VLoc + UpStep) * 16, BaseGraphic);
6534 while(
IsLCAtHV(15, HLoc, (VLoc + DownStep)))
6537 Disp->
PlotOutput(177, HLoc * 16, (VLoc + DownStep) * 16, BaseGraphic);
6542 while(
IsLCAtHV(16, (HLoc + LeftStep), VLoc))
6546 Disp->
PlotOutput(235, (HLoc + LeftStep) * 16, VLoc * 16, RouteGraphic);
6548 Disp->
PlotOutput(236, (HLoc + LeftStep) * 16, VLoc * 16, BaseGraphic);
6554 while(
IsLCAtHV(17, (HLoc + RightStep), VLoc))
6557 Disp->
PlotOutput(238, (HLoc + RightStep) * 16, VLoc * 16, BaseGraphic);
6682 throw Exception(
"Element not found in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
6686 throw Exception(
"Element not a level crossing in LowerLCBarriersAtHV " + AnsiString(HLoc) +
"," + AnsiString(VLoc));
6717 "," + AnsiString(VLoc));
6721 int DummyRouteNumber;
6723 TrainPresent =
false;
6727 while(
IsLCAtHV(25, HLoc, (VLoc + UpStep)))
6729 TrackMapKeyPair.first = HLoc;
6730 TrackMapKeyPair.second = VLoc + UpStep;
6731 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6740 TrainPresent =
true;
6749 while(
IsLCAtHV(26, HLoc, (VLoc + DownStep)))
6751 TrackMapKeyPair.first = HLoc;
6752 TrackMapKeyPair.second = VLoc + DownStep;
6753 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6762 TrainPresent =
true;
6771 while(
IsLCAtHV(27, (HLoc + LeftStep), VLoc))
6773 TrackMapKeyPair.first = HLoc + LeftStep;
6774 TrackMapKeyPair.second = VLoc;
6775 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6784 TrainPresent =
true;
6793 while(
IsLCAtHV(28, (HLoc + RightStep), VLoc))
6795 TrackMapKeyPair.first = HLoc + RightStep;
6796 TrackMapKeyPair.second = VLoc;
6797 TrackMapPtr =
TrackMap.find(TrackMapKeyPair);
6806 TrainPresent =
true;
6823 throw Exception(
"Error, Wrong track type in GetFilletGraphic");
6830 else if(TrackElement.
SpeedTag < 132)
6848 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
6865 AnsiString(ScreenPosV));
6880 AnsiString(ScreenPosV));
6891 AnsiString(VPosTrue));
6905 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
6917 throw Exception(
"CheckMapAndTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
6918 " in TrackMap, Caller=" + (AnsiString)Caller);
6920 if(MapVecPos != (
int)a)
6922 throw Exception(
"CheckMapAndTrack Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
6923 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)MapVecPos +
" TrackVectorPos value=" + (AnsiString)a +
" Caller=" +
6924 (AnsiString)Caller);
6930 throw Exception(
"CheckMapAndTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
6931 " Caller=" + (AnsiString)Caller);
6951 throw Exception(
"CheckMapAndInactiveTrack Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
6952 " in InactiveMap, Caller=" + (AnsiString)Caller);
6954 if((InactivePair.first != a) && (InactivePair.second != a))
6956 throw Exception(
"CheckMapAndInactiveTrack Error - InactiveMapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
6957 (AnsiString)CheckElement.
VLoc +
" Inactive Map values=" + (AnsiString)InactivePair.first +
" and " + (AnsiString)InactivePair.second +
6958 " InactiveTrackVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
6963 throw Exception(
"CheckMapAndInactiveTrack Error - Map Size=" + (AnsiString)
TrackVector.size() +
" TrackVectorSize=" + (AnsiString)
TrackVector.size() +
6964 " Caller=" + (AnsiString)Caller);
6974 int Position1, Position2;
6980 for(GapMapPtr =
GapMap.begin(); GapMapPtr !=
GapMap.end(); GapMapPtr++)
6982 int HLoc1 = GapMapPtr->first.first;
6983 int VLoc1 = GapMapPtr->first.second;
6984 int HLoc2 = GapMapPtr->second.first;
6985 int VLoc2 = GapMapPtr->second.second;
6988 throw Exception(
"Failed to find H & V for gap1, GapMap in error");
6992 throw Exception(
"Failed to find H & V for gap2, GapMap in error");
6996 throw Exception(
"Element at Pos1 not a gap, GapMap in error");
7000 throw Exception(
"Element at Pos2 not a gap, GapMap in error");
7004 unsigned int GapCount = 0;
7006 for(
unsigned int a = 0; a <
TrackVector.size(); a++)
7012 if((
GapMap.size() * 2) != GapCount)
7014 throw Exception(
"GapMap Error - Map Size * 2 =" + (AnsiString)(
GapMap.size() * 2) +
" GapCount=" + (AnsiString)GapCount +
" Caller=" +
7015 (AnsiString)Caller);
7025 if((TrackElement.
HLoc == -2000000000) || (TrackElement.
VLoc == -2000000000))
7029 throw Exception(
"Error - TrackFinished with erase element still present");
7034 AnsiString IDString;
7036 if(TrackElement.
HLoc < 0)
7037 IDString =
"N" + AnsiString(abs(TrackElement.
HLoc)) +
"-";
7039 IDString = AnsiString(TrackElement.
HLoc) +
"-";
7040 if(TrackElement.
VLoc < 0)
7041 IDString +=
"N" + AnsiString(abs(TrackElement.
VLoc));
7043 IDString += AnsiString(TrackElement.
VLoc);
7056 for(
int x = 1; x < String.Length() + 1; x++)
7058 if(String.IsDelimiter(
"-", x))
7063 if(x == String.Length())
7066 ShowMessage(
"Error in track element identifier: <" + String +
"> - no delimiter");
7074 ShowMessage(
"Error in track element identifier: <" + String +
"> - No Horizontal value");
7078 if(DelimPos == String.Length())
7081 ShowMessage(
"Error in track element identifier <" + String +
"> - No Vertical value");
7085 if((String[String.Length()] <
'0') || (String[String.Length()] >
'9'))
7088 ShowMessage(
"Error in track element identifier <" + String +
"> - Last value is not a number");
7094 if(String.SubString(1, 1) !=
"N")
7096 for(
int x = 1; x < DelimPos; x++)
7098 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7101 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
7107 if(String.SubString(1, 1) ==
"N")
7109 for(
int x = 2; x < DelimPos; x++)
7111 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7114 ShowMessage(
"Invalid character in Horizontal value in track element identifier: <" + String +
">");
7120 if(String.SubString(1, 1) ==
"N")
7121 HLoc = -(String.SubString(2, DelimPos - 2).ToInt());
7123 HLoc = String.SubString(1, DelimPos - 1).ToInt();
7125 if(String.SubString(DelimPos + 1, 1) !=
"N")
7127 for(
int x = DelimPos + 1; x < String.Length() + 1; x++)
7129 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7132 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
7138 if(String.SubString(DelimPos + 1, 1) ==
"N")
7140 for(
int x = DelimPos + 2; x < String.Length() + 1; x++)
7142 if((String.SubString(x, 1) <
"0") || (String.SubString(x, 1) >
"9"))
7145 ShowMessage(
"Invalid character in Vertical value in track element identifier: <" + String +
">");
7151 if(String.SubString(DelimPos + 1, 1) ==
"N")
7152 VLoc = -(String.SubString(DelimPos + 2, String.Length() - DelimPos - 1).ToInt());
7154 VLoc = String.SubString(DelimPos + 1, String.Length() - DelimPos).ToInt();
7159 TrackMapPtr =
TrackMap.find(HVPair);
7163 ShowMessage(
"No track element corresponding to track element identifier: <" + String +
">");
7168 return TrackMapPtr->second;
7179 AnsiString(TrackElement.
VLoc) +
"," + AnsiString(TrackElement.
SpeedTag));
7180 int HLoc = TrackElement.
HLoc;
7181 int VLoc = TrackElement.
VLoc;
7284 AnsiString(SpeedTag));
7295 if(HVRange.first == HVRange.second)
7301 HVIt1 = HVRange.first;
7305 if(--HVRange.second != HVRange.first)
7307 HVIt2 = HVRange.second;
7311 HVIt2->second).
SpeedTag == SpeedTag)))
7331 AnsiString(SpeedTag));
7397 AnsiString TestString1, TestString2;
7402 throw Exception(
"LNPendingList size not 1 on entry");
7404 int CurrentElementNumber;
7410 int H = CurrentElement->HLoc;
7411 int V = CurrentElement->VLoc;
7412 int Tag = CurrentElement->SpeedTag;
7418 for(
int x = 0; x < 25; x++)
7428 for(
int x = 0; x < 25; x++)
7438 for(
int x = 0; x < 25; x++)
7448 for(
int x = 0; x < 25; x++)
7458 for(
int x = 0; x < 28; x++)
7468 for(
int x = 0; x < 8; x++)
7478 for(
int x = 0; x < 8; x++)
7488 for(
int x = 0; x < 4; x++)
7498 for(
int x = 0; x < 8; x++)
7508 for(
int x = 0; x < 8; x++)
7521 if(CurrentElementNumber > -1)
7526 if((ExistingName !=
"") && (ExistingName != LocationName))
7540 AddName(1, CurrentElement, LocationName);
7544 LNDone2MultiMapEntry.first = HVPair;
7555 bool FoundFlag, ErasedFlag =
false;
7557 if(SNRange.first != SNRange.second)
7561 for(SNIterator = SNRange.second; SNIterator != SNRange.first; SNIterator--)
7568 TVIt->LocationName =
"";
7569 TVIt->ActiveTrackElementName =
"";
7604 AnsiString(SpeedTag));
7614 if((SpeedTag == 129) || (SpeedTag == 130) || (SpeedTag == 145) || (SpeedTag == 146))
7621 int MapPos = -1 - Position;
7625 FoundElement = MapPos;
7641 FoundElement = IMPair.first;
7650 FoundElement = IMPair.second;
7671 AnsiString OldName = TrackElement->LocationName, ErrorString;
7673 TrackElement->LocationName = Name;
7674 int HLoc = TrackElement->HLoc;
7675 int VLoc = TrackElement->VLoc;
7689 if(ErrorString !=
"")
7691 throw Exception(ErrorString +
" in AddName for OldName == " + OldName);
7715 if(LNDone2MultiMapIterator->second == MapPos)
7742 if(*LNPendingListIterator == MapPos)
7808 if(LocationName ==
"")
7819 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
7824 ActiveTrackElementNameMapEntry.first =
Track->
TrackVector.at(x).ActiveTrackElementName;
7825 ActiveTrackElementNameMapEntry.second = 0;
7847 bool FoundFlag, ErasedFlag =
false;
7851 if(SNRange.first != SNRange.second)
7854 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
7857 TVIt->LocationName =
"";
7858 TVIt->ActiveTrackElementName =
"";
7890 AnsiString(VLoc) +
"," + AnsiString(SpeedTag));
7892 AnsiString LocationName;
7901 if(LocationName !=
"")
7909 if(LocationName !=
"")
7923 if(LocationName !=
"")
7925 int ModifiedPosition = -1 - Position;
7935 for(
int x = 0; x < 25; x++)
7945 else if(SpeedTag == 77)
7947 for(
int x = 0; x < 25; x++)
7957 else if(SpeedTag == 78)
7959 for(
int x = 0; x < 25; x++)
7969 else if(SpeedTag == 79)
7971 for(
int x = 0; x < 25; x++)
7981 else if(SpeedTag == 96)
7983 for(
int x = 0; x < 28; x++)
7993 else if(SpeedTag == 129)
7995 for(
int x = 0; x < 8; x++)
8005 else if(SpeedTag == 130)
8007 for(
int x = 0; x < 8; x++)
8017 else if(SpeedTag == 145)
8019 for(
int x = 0; x < 8; x++)
8029 else if(SpeedTag == 146)
8031 for(
int x = 0; x < 8; x++)
8041 else if(SpeedTag == 131)
8043 for(
int x = 0; x < 4; x++)
8066 AnsiString(SpeedTag));
8078 if(TempElement->LocationName !=
"")
8080 LocationName = TempElement->LocationName;
8081 FoundElement = IMPair.first;
8089 if(TempElement->LocationName !=
"")
8091 LocationName = TempElement->LocationName;
8092 FoundElement = IMPair.second;
8105 if(TempElement->LocationName !=
"")
8107 LocationName = TempElement->LocationName;
8108 FoundElement = -1 - Position;
8124 unsigned int Count = 0;
8132 AnsiString SName, TName, ErrorString;
8134 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8140 throw Exception(
"Track element has FixedNamedLocationElement set but is not a footbridge/underpass in CheckLocationNameMultiMap, caller = " +
8141 AnsiString(Caller));
8154 (
"Inactive track element has FixedNamedLocationElement set but is not a platform, concourse or named location in CheckLocationNameMultiMap, caller = " +
8155 AnsiString(Caller));
8162 throw Exception(
"LocationNameMultiMap size = " + AnsiString(
LocationNameMultiMap.size()) +
" & Count = " + AnsiString(Count) +
8163 " in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
8169 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8175 if(ErrorString !=
"")
8177 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for TrackVector check, caller = " + AnsiString(Caller));
8179 if(SNIt->second != -1 - (
int)x)
8181 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
8182 AnsiString(Caller));
8188 bool FoundFlag =
false;
8197 throw Exception(
"Track element with ActiveTrackElementName but no plat/named loc at H " + AnsiString(
TrackVector.at(x).HLoc) +
" & V " +
8198 AnsiString(
TrackVector.at(x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
8202 throw Exception(
"Track element with ActiveTrackElementName " + TName +
" but plat/named loc at H " + AnsiString(
TrackVector.at(x).HLoc) +
8203 " & V " + AnsiString(
TrackVector.at(x).VLoc) +
" has different LocationName in CheckLocationNameMultiMap, caller = " +
8204 AnsiString(Caller));
8209 throw Exception(
"Track element with ActiveTrackElementName but no inactive element at H " + AnsiString(
TrackVector.at(x).HLoc) +
" & V " +
8210 AnsiString(
TrackVector.at(x).VLoc) +
" in CheckLocationNameMultiMap, caller = " + AnsiString(Caller));
8220 if(ErrorString !=
"")
8222 throw Exception(ErrorString +
" in CheckLocationNameMultiMap for InactiveTrackVector check, caller = " + AnsiString(Caller));
8224 if(SNIt->second != (
int)x)
8226 throw Exception(
"Elements different in name map & TrackVector in CheckLocationNameMultiMap for TrackVector check, caller = " +
8227 AnsiString(Caller));
8237 AnsiString &ErrorString)
8245 AnsiString(TrackElement->HLoc) +
"," + AnsiString(TrackElement->VLoc) +
"," + AnsiString(TrackElement->SpeedTag));
8247 bool FoundFlag =
false;
8251 if(SNRange.first == SNRange.second)
8253 ErrorString =
"Error, Name " + LocationName +
" not found in map";
8255 return SNRange.first;
8259 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
8261 if(SNIterator->second < 0)
8263 int TVPos = -1 - SNIterator->second;
8265 if(TVIt == TrackElement)
8274 int ITVPos = SNIterator->second;
8276 if(ITVIt == TrackElement)
8286 ErrorString =
"Error, Name " + LocationName +
" found but not at required element";
8302 LocationNameEntry.first = NewName;
8303 LocationNameEntry.second = SNIterator->second;
8317 int TruePos = -1 - Position;
8321 throw Exception(
"Footbridge/underpass error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
8331 throw Exception(
"Inactive element error in GetTrackVectorIteratorFromNamePosition, caller = " + AnsiString(Caller));
8354 InactiveTrack2MultiMapIterator++)
8356 if(InactiveTrack2MultiMapIterator->second > VecPos)
8357 InactiveTrack2MultiMapIterator->second--;
8364 LocationNameMultiMapIterator++)
8366 if(LocationNameMultiMapIterator->second < 0)
8368 if(LocationNameMultiMapIterator->second > (
int)VecPos)
8369 LocationNameMultiMapIterator->second--;
8390 for(TrackMapIterator =
TrackMap.begin(); TrackMapIterator !=
TrackMap.end(); TrackMapIterator++)
8392 if(TrackMapIterator->second > VecPos)
8393 TrackMapIterator->second--;
8400 LocationNameMultiMapIterator++)
8402 if(LocationNameMultiMapIterator->second >= 0)
8406 if(LocationNameMultiMapIterator->second < -(
int)(VecPos + 1))
8407 LocationNameMultiMapIterator->second++;
8410 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8416 if(TkEl.
Conn[0] ==
int(VecPos))
8421 if(TkEl.
Conn[0] >
int(VecPos))
8423 if(TkEl.
Conn[0] > -1)
8447 for(
unsigned int TVPos = 0; TVPos <
TrackVector.size(); TVPos++)
8453 LocationNameEntry.second = -1 - TVPos;
8464 LocationNameEntry.second = ITVPos;
8506 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8538 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8562 AnsiString((
short)FirstTrack));
8563 bool LengthDifferent =
false, SpeedDifferent =
false;
8571 int EXArray[16][2] =
8573 {2, 4}, {6, 2}, {8, 6}, {4, 8},
8574 {1, 6}, {3, 8}, {9, 4}, {7, 2}, {1, 8}, {3, 4}, {9, 2}, {7, 6},
8577 int Index = -1, BrNum = -1, GrNum = -1, InLink, OutLink;
8578 Graphics::TBitmap *Bitmap;
8582 InLink = TrackElement.
Link[0];
8583 OutLink = TrackElement.
Link[1];
8587 InLink = TrackElement.
Link[2];
8588 OutLink = TrackElement.
Link[3];
8591 for(
int x = 0; x < 16; x++)
8593 if((InLink == EXArray[x][0] && OutLink == EXArray[x][1]) || (InLink == EXArray[x][1] && OutLink == EXArray[x][0]))
8598 throw Exception(
"Error, failed to find Index in TTrack::MarkOneLength");
8616 else if(TrackElement.
SpeedTag == 54)
8618 else if(TrackElement.
SpeedTag == 55)
8625 else if(TrackElement.
SpeedTag == 58)
8627 else if(TrackElement.
SpeedTag == 59)
8630 else if(Index == 14)
8634 else if(TrackElement.
SpeedTag == 52)
8636 else if(TrackElement.
SpeedTag == 57)
8639 else if(Index == 15)
8643 else if(TrackElement.
SpeedTag == 53)
8645 else if(TrackElement.
SpeedTag == 56)
8655 if(LengthDifferent && SpeedDifferent)
8696 else if(LengthDifferent && !SpeedDifferent)
8790 AnsiString((
short)FirstTrack));
8791 LengthDifferent =
false;
8792 SpeedDifferent =
false;
8797 LengthDifferent =
true;
8801 SpeedDifferent =
true;
8803 if(LengthDifferent || SpeedDifferent)
8816 LengthDifferent =
true;
8820 SpeedDifferent =
true;
8822 if(LengthDifferent || SpeedDifferent)
8835 LengthDifferent =
true;
8839 SpeedDifferent =
true;
8841 if(LengthDifferent || SpeedDifferent)
8921 AnsiString TempName;
8922 int VecPos, StartVecPos, Count, EntryPos, StartEntryPos, ForwardNumber, ReverseNumber;
8923 bool ForwardSet, ReverseSet;
8925 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8930 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
8968 for(
int y = 0; y < 2; y++)
8999 StartElement = TempElement;
9000 StartVecPos = VecPos;
9004 StartEntryPos = 1 - Dir;
9013 VecPos = TempElement.
Conn[1 - EntryPos];
9014 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
9016 EntryPos = TempEntryPos;
9044 ForwardNumber = ((Count + 1) / 2) + 1;
9045 ReverseNumber = (Count - ForwardNumber) + 1;
9048 TempElement = StartElement;
9049 VecPos = StartVecPos;
9050 if(Count == ForwardNumber)
9055 if(Count == ReverseNumber)
9063 VecPos = TempElement.
Conn[1 - EntryPos];
9064 int TempEntryPos = TempElement.
ConnLinkPos[1 - EntryPos];
9066 EntryPos = TempEntryPos;
9068 if(Count == ForwardNumber)
9073 if(Count == ReverseNumber)
9085 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9087 if(
TrackVector.at(x).StationEntryStopLinkPos1 == 5)
9091 if(
TrackVector.at(x).StationEntryStopLinkPos2 == 5)
9199 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
9235 if((TextH / 16) - 1 <
HLocMin)
9237 if((TextH / 16) + 1 >
HLocMax)
9239 if((TextV / 16) - 1 <
VLocMin)
9241 if((TextV / 16) + 1 >
VLocMax)
9261 void TTrack::UserGraphicMove(
int Caller,
int HPosInput,
int VPosInput,
int &UserGraphicItem,
int &UserGraphicMoveHPos,
int &UserGraphicMoveVPos,
9262 bool &UserGraphicFoundFlag)
9265 TUserGraphicVector::iterator UserGraphicPtr;
9267 UserGraphicFoundFlag =
false;
9274 if((HPosInput >= (*UserGraphicPtr).HPos) && (HPosInput < ((*UserGraphicPtr).HPos + (*UserGraphicPtr).Width)) && (VPosInput >=
9275 (*UserGraphicPtr).VPos) && (VPosInput < ((*UserGraphicPtr).VPos + (*UserGraphicPtr).Height)))
9277 UserGraphicItem = x;
9278 UserGraphicMoveHPos = (*UserGraphicPtr).HPos;
9279 UserGraphicMoveVPos = (*UserGraphicPtr).VPos;
9280 UserGraphicFoundFlag =
true;
9296 int SpeedTag = TrackElement.
SpeedTag;
9300 throw Exception(
"Error - SpeedTag value " + AnsiString(SpeedTag) +
" in RetrieveStripedNamedLocationGraphicsWhereRelevant");
9349 return GraphicOutput;
9357 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
9359 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in TrackElementAt");
9372 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
InactiveTrackVector.size()) +
", At: " + AnsiString(At) +
9373 " in InactiveTrackElementAt");
9384 if((At < 0) || ((
unsigned int)At >=
TrackVector.size()))
9386 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in BlankElementAt");
9411 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
9412 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
9416 if(SNRange.first == SNRange.second)
9421 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9423 if(SNIterator->second < 0)
9429 HVPair.first = InactiveElement.
HLoc;
9430 HVPair.second = InactiveElement.
VLoc;
9434 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in OneNamedLocationLongEnoughForSplit (1)");
9436 int TVPos =
TrackMap.find(HVPair)->second;
9439 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
9445 FirstNamedExitPos = 0;
9449 FirstNamedLinkedElement =
TrackElementAt(562, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9450 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9453 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9455 SecondNamedLinkedElement =
TrackElementAt(563, SecondNamedElement.
Conn[SecondNamedExitPos]);
9456 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9457 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9460 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9470 FirstNamedExitPos = 1;
9474 FirstNamedLinkedElement =
TrackElementAt(565, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9475 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9478 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9480 SecondNamedLinkedElement =
TrackElementAt(566, SecondNamedElement.
Conn[SecondNamedExitPos]);
9481 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9482 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9485 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9500 int &FirstNamedLinkedElementPos,
int &SecondNamedLinkedElementPos)
9514 AnsiString(FirstNamedElementPos));
9515 TTrackElement InactiveElement, FirstNamedElement, SecondNamedElement, FirstNamedLinkedElement, SecondNamedLinkedElement;
9516 int FirstNamedExitPos, SecondNamedExitPos, FirstNamedLinkedExitPos, SecondNamedLinkedEntryPos;
9518 SecondNamedElementPos = -1;
9519 FirstNamedLinkedElementPos = -1;
9520 SecondNamedLinkedElementPos = -1;
9524 if(SNRange.first == SNRange.second)
9529 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9531 if(SNIterator->second < 0)
9537 HVPair.first = InactiveElement.
HLoc;
9538 HVPair.second = InactiveElement.
VLoc;
9550 (
"Error - failed to find element in TrackMap for a non-concourse element in LocationNameMultiMap in ThisNamedLocationLongEnoughForSplit (2)"
9554 int TVPos =
TrackMap.find(HVPair)->second;
9555 if(TVPos != FirstNamedElementPos)
9559 if((FirstNamedElement.
Conn[0] == -1) || (FirstNamedElement.
Conn[1] == -1))
9565 FirstNamedExitPos = 0;
9569 FirstNamedLinkedElement =
TrackElementAt(569, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9570 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9573 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9575 SecondNamedLinkedElement =
TrackElementAt(570, SecondNamedElement.
Conn[SecondNamedExitPos]);
9576 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9577 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9580 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9582 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
9583 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
9584 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
9593 FirstNamedExitPos = 1;
9597 FirstNamedLinkedElement =
TrackElementAt(572, FirstNamedElement.
Conn[1 - FirstNamedExitPos]);
9598 FirstNamedLinkedExitPos = FirstNamedElement.
ConnLinkPos[1 - FirstNamedExitPos];
9601 if(SecondNamedElement.
Conn[SecondNamedExitPos] > -1)
9603 SecondNamedLinkedElement =
TrackElementAt(573, SecondNamedElement.
Conn[SecondNamedExitPos]);
9604 SecondNamedLinkedEntryPos = SecondNamedElement.
ConnLinkPos[SecondNamedExitPos];
9605 if((SecondNamedLinkedElement.
TrackType !=
Points) || (SecondNamedLinkedEntryPos != 3))
9608 if((FirstNamedLinkedElement.
TrackType !=
Points) || (FirstNamedLinkedExitPos != 3))
9610 SecondNamedElementPos = FirstNamedElement.
Conn[FirstNamedExitPos];
9611 FirstNamedLinkedElementPos = FirstNamedElement.
Conn[1 - FirstNamedExitPos];
9612 SecondNamedLinkedElementPos = SecondNamedElement.
Conn[SecondNamedExitPos];
9632 if(SNRange.first != SNRange.second)
9634 for(SNIterator = SNRange.first; SNIterator != SNRange.second; SNIterator++)
9636 if(SNIterator->second < 0)
9656 "," + AnsiString(SpeedTag));
9667 throw Exception(
"Error, FoundFlag false in PlatformOnSignalSide after IsPlatformOrNamedNonStationLocationPresent called successfully");
9693 else if(SpeedTag == 69)
9715 else if(SpeedTag == 70)
9737 else if(SpeedTag == 71)
9770 AnsiString(NextEntryPos) +
"," + AnsiString(OwnTrainID));
9771 if(NextEntryPos < 0)
9784 if(NextEntryPos > 1)
9803 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrackVector.size()) +
", At: " + AnsiString(At) +
" in SelectVectorAt");
9815 AnsiString(VLocIn) +
"," + AnsiString(LinkIn));
9816 bool FoundFlag =
false;
9831 int VLocHi = -2000000000, VLocLo = 2000000000, HLoc = 2000000000;
9832 bool FoundFlag =
false;
9851 VPosHi = 16 * VLocHi;
9852 VPosLo = 16 * VLocLo;
9871 AnsiString(EndTVPosition));
9882 int Link0Squares = ((EndElement.
HLoc - NewHLocLink0) * (EndElement.
HLoc - NewHLocLink0)) +
9883 ((EndElement.
VLoc - NewVLocLink0) * (EndElement.
VLoc - NewVLocLink0));
9884 int Link1Squares = ((EndElement.
HLoc - NewHLocLink1) * (EndElement.
HLoc - NewHLocLink1)) +
9885 ((EndElement.
VLoc - NewVLocLink1) * (EndElement.
VLoc - NewVLocLink1));
9887 if(Link0Squares <= Link1Squares)
9904 AnsiString(LinkPos));
9923 if((LinkPos == 1) && (TE.
Attribute == 0))
9928 else if(LinkPos == 1)
9934 else if((LinkPos == 3) && (TE.
Attribute == 1))
9939 else if(LinkPos == 3)
9946 else if(LinkPos == 0)
9951 else if(LinkPos == 1)
9956 else if(LinkPos == 2)
9961 else if(LinkPos == 3)
9966 throw Exception(
"Error, failure in GetExitPos");
10015 if((TE.
Link[0] == Link) || (TE.
Link[1] == Link))
10019 else if((TE.
Link[2] == Link) || (TE.
Link[3] == Link))
10059 "," + AnsiString(DiagonalLinkNumber));
10064 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(8, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
TrainOnLink(9, HLoc - 1, VLoc, 9, TrainID)))
10070 if(((DiagonalLinkNumber == 1) &&
TrainOnLink(10, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
TrainOnLink(11, HLoc, VLoc - 1, 9, TrainID)))
10076 if(((DiagonalLinkNumber == 3) &&
TrainOnLink(12, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(13, HLoc + 1, VLoc, 7, TrainID)))
10082 if(((DiagonalLinkNumber == 7) &&
TrainOnLink(14, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
TrainOnLink(15, HLoc, VLoc + 1, 3, TrainID)))
10099 AnsiString JustFileName =
"";
10104 int LastDelim = UGI.
FileName.LastDelimiter(
'\\');
10111 JustFileName = UGI.
FileName.SubString(LastDelim + 1, UGI.
FileName.Length() - LastDelim);
10130 typedef std::list<int> TNamePosList;
10131 TNamePosList NamePosList;
10132 typedef TNamePosList::iterator TNPLIt;
10134 typedef std::list<int> TOnePlatList;
10135 TOnePlatList OnePlatList;
10136 typedef TOnePlatList::iterator TOPLIt;
10139 NamePosList.clear();
10140 OnePlatList.clear();
10141 for(
unsigned int x = 0; x <
TrackVector.size(); x++)
10143 if(
TrackElementAt(988, x).ActiveTrackElementName == LocationName)
10145 NamePosList.push_back(x);
10150 if(!NamePosList.empty())
10152 OnePlatList.push_back(NamePosList.back());
10153 NamePosList.pop_back();
10156 while(!OnePlatList.empty())
10158 TempInt = OnePlatList.front();
10161 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[0]);
10162 if(NPLIt != NamePosList.end() && ((TempElement.
Link[0] == 2) || (TempElement.
Link[0] == 4) || (TempElement.
Link[0] == 6) || (TempElement.
Link[0] == 8)))
10164 OnePlatList.push_back(TempElement.
Conn[0]);
10165 NamePosList.erase(NPLIt);
10167 NPLIt = find(NamePosList.begin(), NamePosList.end(), TempElement.
Conn[1]);
10168 if(NPLIt != NamePosList.end() && ((TempElement.
Link[1] == 2) || (TempElement.
Link[1] == 4) || (TempElement.
Link[1] == 6) || (TempElement.
Link[1] == 8)))
10170 OnePlatList.push_back(TempElement.
Conn[1]);
10171 NamePosList.erase(NPLIt);
10174 OnePlatList.erase(OnePlatList.begin());
10175 if(OnePlatList.empty())
10178 if(!NamePosList.empty())
10180 OnePlatList.push_back(NamePosList.back());
10181 NamePosList.pop_back();
10198 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
UserGraphicVector.size()) +
", At: " + AnsiString(At) +
" in UserGraphicVectorAt");
10213 throw Exception(
"Return value negative in call to LastElementNumber");
10225 throw Exception(
"PrefDirVector empty in call to LastElementPtr");
10239 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedPrefDirElementAt");
10251 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
PrefDirVector.size()) +
", At: " + AnsiString(At) +
10252 " in GetModifiablePrefDirElementAt");
10262 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
10264 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedSearchElementAt");
10274 if((At < 0) || ((
unsigned int)At >=
SearchVector.size()))
10276 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
SearchVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableSearchElementAt");
10293 int TrackVectorPosition;
10345 FinishElement =
false;
10346 int TrackVectorPosition;
10369 if(TrackElement.
HLoc >= StartPrefDirElement.
HLoc)
10380 if(TrackElement.
VLoc >= StartPrefDirElement.
VLoc)
10403 for(
int x = 0; x < 4; x++)
10426 FinishElement =
true;
10434 for(
int x = 0; x < 4; x++)
10446 FinishElement =
true;
10454 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
10461 .ELinkPos] ==
Lead))
10477 FinishElement =
true;
10496 FinishElement =
true;
10515 FinishElement =
true;
10530 FinishElement =
true;
10539 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
10555 FinishElement =
true;
10561 "Unable to find a route to the selected element - may be unreachable, too far ahead, or invalid. Try selecting an end point closer to the start point.");
10584 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition));
10585 int VectorCount = 0;
10589 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
10591 for(
int x = 0; x < VectorCount; x++)
10596 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
10600 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
10601 SearchElement.
ELinkPos = NextELinkPos;
10614 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
10616 SearchElement.
XLinkPos = NextXLinkPos;
10642 for(
int x = 0; x < VectorCount; x++)
10652 for(
int x = 0; x < VectorCount; x++)
10664 for(
int x = 0; x < VectorCount; x++)
10676 for(
int x = 0; x < VectorCount; x++)
10685 for(
int x = 0; x < VectorCount; x++)
10694 SearchElement.
XLink = SearchElement.
Link[1];
10713 SearchElement.
XLink = SearchElement.
Link[3];
10726 for(
int x = 0; x < VectorCount; x++)
10738 XLinkPos = NextXLinkPos;
10739 CurrentTrackElement = SearchElement;
10758 throw Exception(
"Error, SearchVector empty");
10765 for(
int x = 0; x < 4; x++)
10810 throw Exception(
"Error in EntryExitNumber 1");
10830 if(PrefDirElement.
XLink == -1)
10838 if(PrefDirElement.
XLink != -1)
10842 throw Exception(
"Error in EntryExitNumber 2");
10878 LeadingPoints =
false;
10906 LeadingPoints =
true;
10922 AnsiString ErrorString;
10923 bool Error =
false;
10930 ErrorString =
"HLoc";
10936 ErrorString =
"VLoc";
10942 ErrorString =
"ELink";
10948 ErrorString =
"ELinkPos";
10954 ErrorString =
"XLink";
10960 ErrorString =
"XLinkPos";
10966 ErrorString =
"Tag";
10972 ErrorString =
"TrackVectorPosition";
10978 ErrorString =
"EXNumber";
10985 ErrorString =
"CheckCount";
10992 ErrorString =
"EntryGraphicPtr";
10998 ErrorString =
"EntryDirectionGraphicPtr";
11007 ErrorString =
"Last XLink not connected to this element";
11014 throw Exception(
"Error at " + AnsiString(Position) +
" " + ErrorString);
11038 for(
int PrefDirVecPos = (
PrefDirVector.size() - 1); PrefDirVecPos >= (int)x; PrefDirVecPos--)
11095 AnsiString((
short)BuildingPrefDir));
11098 if(PrefDirSize() == 0)
11103 for(
unsigned int x = 0; x < PrefDirSize(); x++)
11115 Disp->PlotOutput(12, (TempPrefDirElement.
HLoc * 16), (TempPrefDirElement.
VLoc * 16), TempPrefDirElement.
EXGraphicPtr);
11127 if(x == (PrefDirSize() - 1))
11136 if((PrefDirRoute ==
PrefDirCall) && BuildingPrefDir)
11138 HPos = GetFixedPrefDirElementAt(4, 0).
HLoc * 16;
11139 VPos = GetFixedPrefDirElementAt(5, 0).VLoc * 16;
11140 Disp->Rectangle(1, HPos, VPos,
clB0G0R5, 2, 2);
11142 if(PrefDirSize() > 1)
11144 unsigned int LatestPos = PrefDirSize() - 1;
11145 HPos = GetFixedPrefDirElementAt(6, LatestPos).HLoc * 16;
11146 VPos = GetFixedPrefDirElementAt(7, LatestPos).VLoc * 16;
11147 Disp->Rectangle(2, HPos, VPos,
clB5G0R0, 4, 2);
11169 int H, V, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
11172 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
11176 H = MMIT->first.first;
11177 V = MMIT->first.second;
11180 if(PrefDirPos0 > -1)
11182 if(PrefDirPos1 > -1)
11184 if(PrefDirPos2 > -1)
11186 if(PrefDirPos3 > -1)
11188 if(PrefDirPos3 > -1)
11203 else if(PrefDirPos2 > -1)
11242 else if(PrefDirPos1 > -1)
11263 else if(PrefDirPos0 > -1)
11282 int NumberOfPrefDirElements = 0;
11285 for(
int x = 0; x < NumberOfPrefDirElements; x++)
11287 VecFile >> TempInt;
11290 VecFile >> TempInt;
11291 LoadPrefDirElement.
ELink = TempInt;
11292 VecFile >> TempInt;
11293 LoadPrefDirElement.
ELinkPos = TempInt;
11294 VecFile >> TempInt;
11295 LoadPrefDirElement.
XLink = TempInt;
11296 VecFile >> TempInt;
11297 LoadPrefDirElement.
XLinkPos = TempInt;
11298 VecFile >> TempInt;
11299 LoadPrefDirElement.
EXNumber = TempInt;
11300 VecFile >> TempInt;
11305 if(!(LoadPrefDirElement.
IsARoute))
11331 int NumberOfPrefDirElements = 0;
11334 for(
int x = 0; x < NumberOfPrefDirElements; x++)
11336 VecFile >> TempInt;
11337 VecFile >> TempInt;
11340 VecFile >> TempInt;
11341 LoadPrefDirElement.
ELink = TempInt;
11342 VecFile >> TempInt;
11343 LoadPrefDirElement.
ELinkPos = TempInt;
11344 VecFile >> TempInt;
11345 LoadPrefDirElement.
XLink = TempInt;
11346 VecFile >> TempInt;
11347 LoadPrefDirElement.
XLinkPos = TempInt;
11348 VecFile >> TempInt;
11349 LoadPrefDirElement.
EXNumber = TempInt;
11350 VecFile >> TempInt;
11355 if(!(LoadPrefDirElement.
IsARoute))
11383 int NumberOfPrefDirElements = 0;
11386 if((NumberOfPrefDirElements < 0) || (NumberOfPrefDirElements > 1000000))
11391 for(
int x = 0; x < NumberOfPrefDirElements; x++)
11398 VecFile >> TempInt;
11399 if((TempInt < 0) || (TempInt >= NumberOfActiveElements))
11404 VecFile >> TempInt;
11405 if((TempInt < -1) || (TempInt > 9))
11410 VecFile >> TempInt;
11411 if((TempInt < -1) || (TempInt > 3))
11416 VecFile >> TempInt;
11417 if((TempInt < -1) || (TempInt > 9))
11422 VecFile >> TempInt;
11423 if((TempInt < -1) || (TempInt > 3))
11428 VecFile >> TempInt;
11429 if((TempInt < -1) || (TempInt > 27))
11434 VecFile >> TempInt;
11442 VecFile >> TempInt;
11443 if((TempInt != 0) && (TempInt != 1))
11448 VecFile >> TempInt;
11449 if((TempInt != 0) && (TempInt != 1))
11454 VecFile >> TempInt;
11455 if((TempInt != 0) && (TempInt != 1))
11478 for(
int y = 0; y < NumberOfPrefDirElements; y++)
11480 VecFile << y <<
'\n';
11481 VecFile <<
PrefDirVector.at(y).TrackVectorPosition <<
'\n';
11491 if(y == (NumberOfPrefDirElements - 1))
11493 VecFile <<
"************" <<
'\0' <<
'\n';
11497 VecFile <<
"******" <<
'\0' <<
'\n';
11511 for(
int y = 0; y < NumberOfSearchElements; y++)
11513 VecFile << y <<
'\n';
11514 VecFile <<
SearchVector.at(y).TrackVectorPosition <<
'\n';
11524 if(y == (NumberOfSearchElements - 1))
11526 VecFile <<
"************" <<
'\0' <<
'\n';
11530 VecFile <<
"******" <<
'\0' <<
'\n';
11635 bool AlreadyPresent, FoundFlag;
11636 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
11638 for(
unsigned int x = 0; x < InputPrefDir->
PrefDirSize(); x++)
11642 AlreadyPresent =
false;
11646 AlreadyPresent =
true;
11648 AlreadyPresent =
true;
11650 AlreadyPresent =
true;
11652 AlreadyPresent =
true;
11654 if(!AlreadyPresent)
11699 for(
unsigned int z = 0; z < 4; z++)
11707 throw Exception(
"Error in RebuildPrefDirVector - PrefDirVector is unsafe");
11721 bool DiscrepancyFound =
false;
11731 DiscrepancyFound =
true;
11734 DiscrepancyFound =
true;
11739 DiscrepancyFound =
true;
11744 DiscrepancyFound =
true;
11749 DiscrepancyFound =
true;
11754 DiscrepancyFound =
true;
11756 if(DiscrepancyFound)
11758 ShowMessage(
"Discrepancies found in the preferred direction file, preferred directions will be cleared");
11773 bool DiscrepancyFound =
false;
11783 DiscrepancyFound =
true;
11786 DiscrepancyFound =
true;
11791 DiscrepancyFound =
true;
11796 DiscrepancyFound =
true;
11801 DiscrepancyFound =
true;
11806 DiscrepancyFound =
true;
11809 return !DiscrepancyFound;
11821 bool FoundFlag =
false;
11822 int PrefDir0, PrefDir1, PrefDir2, PrefDir3;
11830 throw Exception(
"CheckPrefDir4MultiMap Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
11831 " in PrefDir4MultiMap, Caller=" + (AnsiString)Caller);
11833 if((PrefDir0 != (
int)a) && (PrefDir1 != (
int)a) && (PrefDir2 != (
int)a) && (PrefDir3 != (
int)a))
11835 throw Exception(
"CheckPrefDir4MultiMap Error - MapVectorPosition failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
11836 (AnsiString)CheckElement.
VLoc +
" Map values=" + (AnsiString)PrefDir0 +
", " + (AnsiString)PrefDir1 +
", " + (AnsiString)PrefDir2 +
", " +
11837 (AnsiString)PrefDir3 +
" PrefDirVectorPos value=" + (AnsiString)a +
" Caller=" + (AnsiString)Caller);
11842 throw Exception(
"CheckPrefDir4MultiMap Error - Map Size=" + (AnsiString)
PrefDirVector.size() +
" PrefDirVectorSize=" + (AnsiString)
PrefDirVector.size()
11843 +
" Caller=" + (AnsiString)Caller);
11869 PrefDirMapKeyPair.first = HLoc;
11870 PrefDirMapKeyPair.second = VLoc;
11871 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
11874 if(ItPair.first == ItPair.second)
11882 PrefDirPos0 = ItPair.first->second;
11884 if(ItPair.first == ItPair.second)
11889 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
11890 PrefDirPos1 = ItPair.first->second;
11892 if(ItPair.first == ItPair.second)
11897 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
11898 PrefDirPos2 = ItPair.first->second;
11900 if(ItPair.first == ItPair.second)
11905 if(((ItPair.first->first).first == HLoc) && ((ItPair.first->first).second == VLoc))
11906 PrefDirPos3 = ItPair.first->second;
11920 THVPair PrefDir4MultiMapKeyPair;
11923 PrefDir4MultiMapKeyPair.first = LoadPrefDirElement.
HLoc;
11924 PrefDir4MultiMapKeyPair.second = LoadPrefDirElement.
VLoc;
11925 PrefDir4MultiMapEntry.first = PrefDir4MultiMapKeyPair;
11948 throw Exception(
"Failed to find PrefDir4MultiMap erase element");
11967 AnsiString(ErasedElementNumber));
11972 if(MapPtr->second > ErasedElementNumber)
11992 throw Exception(
"PrefDirVectorPosition out of range");
11995 THVPair PrefDir4MultiMapKeyPair;
11997 PrefDir4MultiMapKeyPair.first = PrefDirElement.
HLoc;
11998 PrefDir4MultiMapKeyPair.second = PrefDirElement.
VLoc;
11999 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
12002 if(ItPair.first == ItPair.second)
12005 return ItPair.first;
12009 if(ItPair.first->second == PrefDirVectorPosition)
12013 return ItPair.first;
12016 if(ItPair.first == ItPair.second)
12019 return ItPair.first;
12021 if(ItPair.first->second == PrefDirVectorPosition)
12025 return ItPair.first;
12028 if(ItPair.first == ItPair.second)
12031 return ItPair.first;
12033 if(ItPair.first->second == PrefDirVectorPosition)
12037 return ItPair.first;
12040 if(ItPair.first == ItPair.second)
12043 return ItPair.first;
12045 if(ItPair.first->second == PrefDirVectorPosition)
12049 return ItPair.first;
12053 return ItPair.first;
12066 THVPair PrefDir4MultiMapKeyPair;
12068 PrefDir4MultiMapKeyPair.first = HLoc;
12069 PrefDir4MultiMapKeyPair.second = VLoc;
12070 std::pair<TPrefDir4MultiMapIterator, TPrefDir4MultiMapIterator>ItPair;
12073 if(ItPair.first == ItPair.second)
12081 return ItPair.first->second;
12090 bool ErasedFlag =
false;
12092 if(ErasedTrackVectorPosition > -1)
12101 ErasedFlag =
false;
12103 if(
PrefDirVector.at(x).TrackVectorPosition == ErasedTrackVectorPosition)
12108 else if(
PrefDirVector.at(x).Conn[0] == ErasedTrackVectorPosition)
12113 else if(
PrefDirVector.at(x).Conn[1] == ErasedTrackVectorPosition)
12118 else if(
PrefDirVector.at(x).Conn[2] == ErasedTrackVectorPosition)
12123 else if(
PrefDirVector.at(x).Conn[3] == ErasedTrackVectorPosition)
12131 if(
PrefDirVector.at(x).TrackVectorPosition > ErasedTrackVectorPosition)
12135 if(
PrefDirVector.at(x).Conn[0] > ErasedTrackVectorPosition)
12139 if(
PrefDirVector.at(x).Conn[1] > ErasedTrackVectorPosition)
12143 if(
PrefDirVector.at(x).Conn[2] > ErasedTrackVectorPosition)
12147 if(
PrefDirVector.at(x).Conn[3] > ErasedTrackVectorPosition)
12162 OverallDistance = 0;
12163 OverallSpeedLimit = 0;
12164 LeadingPointsAtLastElement =
false;
12173 LeadingPointsAtLastElement =
true;
12182 OverallDistance += PrefDirElement.
Length23;
12183 if(OverallSpeedLimit != -1)
12193 OverallSpeedLimit = -1;
12200 OverallDistance += PrefDirElement.
Length01;
12201 if(OverallSpeedLimit != -1)
12211 OverallSpeedLimit = -1;
12231 int H, V, HLoc, VLoc, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12234 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
12238 HLoc = MMIT->first.first;
12239 VLoc = MMIT->first.second;
12244 if(PrefDirPos0 > -1)
12246 if(PrefDirPos1 > -1)
12248 if(PrefDirPos2 > -1)
12250 if(PrefDirPos3 > -1)
12252 if(PrefDirPos3 > -1)
12254 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12256 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12258 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
12260 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement3.
GetRouteGraphicPtr(
false,
true));
12267 else if(PrefDirPos2 > -1)
12271 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12273 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12275 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
false));
12283 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12285 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
12287 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
12295 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12297 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement2.
GetRouteGraphicPtr(
false,
true));
12299 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
12306 else if(PrefDirPos1 > -1)
12310 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
true));
12312 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
true));
12319 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
12321 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement1.
GetRouteGraphicPtr(
false,
false));
12327 else if(PrefDirPos0 > -1)
12329 Bitmap->Canvas->Draw((H * 16), (V * 16), PrefDirElement0.
GetRouteGraphicPtr(
false,
false));
12346 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12349 TPrefDirElement PrefDirElement0, PrefDirElement1, PrefDirElement2, PrefDirElement3;
12370 if(PrefDirPos0 > -1)
12372 if(PrefDirPos1 > -1)
12374 if(PrefDirPos2 > -1)
12376 if(PrefDirPos3 > -1)
12379 if(PrefDirPos3 > -1)
12384 else if(PrefDirPos2 > -1)
12386 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos) || (PrefDirElement2.
XLinkPos == EntryPos))
12397 else if(PrefDirPos1 > -1)
12399 if((PrefDirElement0.
XLinkPos == EntryPos) || (PrefDirElement1.
XLinkPos == EntryPos))
12410 else if(PrefDirPos0 > -1)
12412 if(PrefDirElement0.
XLinkPos == EntryPos)
12449 ElementIn.
VLoc +
"," + XLink);
12451 bool TrackFoundFlag;
12454 if((XLink == 2) || (XLink == 4) || (XLink == 6) || (XLink == 8))
12467 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
12477 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
12492 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
12502 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
12517 if((TempTrackElement.
Link[0] == 9) || (TempTrackElement.
Link[1] == 9) || (TempTrackElement.
Link[2] == 9) || (TempTrackElement.
Link[3] == 9))
12527 if((TempTrackElement.
Link[0] == 1) || (TempTrackElement.
Link[1] == 1) || (TempTrackElement.
Link[2] == 1) || (TempTrackElement.
Link[3] == 1))
12542 if((TempTrackElement.
Link[0] == 7) || (TempTrackElement.
Link[1] == 7) || (TempTrackElement.
Link[2] == 7) || (TempTrackElement.
Link[3] == 7))
12552 if((TempTrackElement.
Link[0] == 3) || (TempTrackElement.
Link[1] == 3) || (TempTrackElement.
Link[2] == 3) || (TempTrackElement.
Link[3] == 3))
12575 bool FoundFlag, ContFlag, FoundElements =
false;
12576 int PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3;
12581 LastIteratorValue++;
12602 if(PDVIt->XLinkPos == 0)
12607 StartElement = *PDVIt;
12616 int NextTrackVectorPosition = PDVIt->
Conn[PDVIt->GetXLinkPos()];
12618 Track->
TrackElementAt(879, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
12619 if(PrefDirPos0 == -1)
12623 bool NextElementFoundFlag =
false;
12627 NextElementFoundFlag =
true;
12629 if(PrefDirPos1 > -1)
12634 NextElementFoundFlag =
true;
12637 if(PrefDirPos2 > -1)
12642 NextElementFoundFlag =
true;
12645 if(PrefDirPos3 > -1)
12650 NextElementFoundFlag =
true;
12653 if(!NextElementFoundFlag)
12683 EndElement = NextElement;
12687 NextTrackVectorPosition = NextElement.
Conn[NextElement.
GetXLinkPos()];
12689 Track->
TrackElementAt(881, NextTrackVectorPosition).
VLoc, FoundFlag, PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
12690 if(PrefDirPos0 == -1)
12700 if(PrefDirPos1 > -1)
12708 if(PrefDirPos2 > -1)
12716 if(PrefDirPos3 > -1)
12745 FoundElements =
true;
12809 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
12811 int TrackVectorPosition;
12820 if(ConsecSignalsRoute)
12863 int LockedVectorNumber;
12887 bool InPrefDirFlag =
false;
12890 int PrefDirPos0 = -1;
12891 int PrefDirPos1 = -1;
12892 int PrefDirPos2 = -1;
12893 int PrefDirPos3 = -1;
12897 int PrefDirVecPos[4] =
12898 {PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3};
12900 for(
int x = 0; x < 4; x++)
12902 int b = PrefDirVecPos[x];
12905 if(ConsecSignalsRoute)
12914 InPrefDirFlag =
true;
12932 InPrefDirFlag =
true;
12938 InPrefDirFlag =
true;
12951 "Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
12960 if(DummyPair.first > -1)
12962 throw Exception(
"Selection in two routes - should never happen!");
12965 if(RoutePair.first > -1)
12995 if(ConsecSignalsRoute)
13045 IDInt &ReqPosRouteID,
bool &PointsChanged)
13085 AnsiString(VLoc) +
"," + AnsiString((
short)AutoSigsFlag));
13124 if(ConsecSignalsRoute)
13153 bool InPrefDirFlag =
false;
13156 int PrefDirPos0 = -1;
13157 int PrefDirPos1 = -1;
13158 int PrefDirPos2 = -1;
13159 int PrefDirPos3 = -1;
13162 PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3);
13163 int PrefDirVecPos[4] =
13164 {PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3};
13166 for(
int x = 0; x < 4; x++)
13168 int b = PrefDirVecPos[x];
13171 InPrefDirFlag =
true;
13181 "Route and preferred direction mismatch. If no preferred direction then only red routes can be used. Green and blue route directions must correspond to the preferred direction.");
13191 if(RoutePair.first > -1)
13193 if(RoutePair.second != 0)
13210 EndElement1 = RouteElement;
13211 EndElement2 = BlankElement;
13316 PointsChanged =
true;
13341 PointsChanged =
true;
13362 PointsChanged =
true;
13390 PointsChanged =
true;
13404 PointsChanged =
true;
13420 PointsChanged =
true;
13431 PointsChanged =
true;
13447 PointsChanged =
true;
13499 TOnePrefDir *EveryPrefDir,
bool ConsecSignalsRoute,
int EndPosition,
bool AutoSigsFlag)
13552 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString(
ReqPosRouteID.
GetInt()) +
"," + AnsiString(EndPosition) +
"," +
13553 AnsiString((
short)AutoSigsFlag));
13554 int VectorCount = 0;
13558 if((PrefDirElement.
XLink == 1) || (PrefDirElement.
XLink == 3) || (PrefDirElement.
XLink == 7) || (PrefDirElement.
XLink == 9))
13562 for(
int x = 0; x < VectorCount; x++)
13569 bool FirstPass =
true;
13579 for(
int x = 0; x < VectorCount; x++)
13586 for(
int x = 0; x < VectorCount; x++)
13591 if(!FirstPass && (ConsecSignalsRoute) && (PrefDirElement.
Config[PrefDirElement.
XLinkPos] ==
Signal))
13596 for(
int x = 0; x < VectorCount; x++)
13602 int NextPosition = PrefDirElement.
Conn[XLinkPos];
13606 int NextELinkPos = PrefDirElement.
ConnLinkPos[XLinkPos];
13607 SearchElement.
ELinkPos = NextELinkPos;
13608 SearchElement.
ELink = SearchElement.
Link[NextELinkPos];
13621 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
13623 SearchElement.
XLinkPos = NextXLinkPos;
13635 for(
int x = 0; x < VectorCount; x++)
13647 if(RoutePair.first > -1)
13656 for(
int x = 0; x < VectorCount; x++)
13663 if(SecondPair.first > -1)
13672 for(
int x = 0; x < VectorCount; x++)
13685 for(
int x = 0; x < VectorCount; x++)
13694 for(
int x = 0; x < VectorCount; x++)
13701 for(
int x = 0; x < VectorCount; x++)
13709 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
13713 for(
int x = 0; x < VectorCount; x++)
13721 bool InPrefDirFlag =
false;
13722 PrefDirElement1 = BlankElement;
13723 PrefDirElement2 = BlankElement;
13726 int PrefDirPos0 = -1;
13727 int PrefDirPos1 = -1;
13728 int PrefDirPos2 = -1;
13729 int PrefDirPos3 = -1;
13732 int PrefDirVecPos[4] =
13733 {PrefDirPos0, PrefDirPos1, PrefDirPos2, PrefDirPos3};
13734 for(
int x = 0; x < 4; x++)
13736 int b = PrefDirVecPos[x];
13739 InPrefDirFlag =
true;
13748 for(
int x = 0; x < VectorCount; x++)
13759 for(
int x = 0; x < VectorCount; x++)
13772 for(
int x = 0; x < VectorCount; x++)
13781 if(ConsecSignalsRoute)
13792 for(
int x = 0; x < VectorCount; x++)
13806 for(
int x = 0; x < VectorCount; x++)
13814 for(
int x = 0; x < VectorCount; x++)
13823 int SearchPos1 = SearchElement.
Attribute + 1;
13825 if(SearchPos1 == 2)
13827 if(SearchPos1 == 1)
13831 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
13832 SearchElement.
XLinkPos = SearchPos1;
13833 InPrefDirFlag =
false;
13834 if(SearchElement.
XLink == PrefDirElement1.
XLink)
13836 SearchElement = PrefDirElement1;
13837 InPrefDirFlag =
true;
13839 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
13841 SearchElement = PrefDirElement2;
13842 InPrefDirFlag =
true;
13848 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
13852 for(
int x = 0; x < VectorCount; x++)
13862 if(ConsecSignalsRoute)
13880 for(
int x = 0; x < VectorCount; x++)
13896 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
13897 SearchElement.
XLinkPos = SearchPos2;
13898 if(SearchElement.
XLink == PrefDirElement1.
XLink)
13900 SearchElement = PrefDirElement1;
13902 else if(SearchElement.
XLink == PrefDirElement2.
XLink)
13904 SearchElement = PrefDirElement2;
13908 for(
int x = 0; x < VectorCount; x++)
13914 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
13918 for(
int x = 0; x < VectorCount; x++)
13929 if(ConsecSignalsRoute)
13947 for(
int x = 0; x < VectorCount; x++)
13957 for(
int x = 0; x < VectorCount; x++)
13964 SearchElement = PrefDirElement1;
13969 if(ConsecSignalsRoute)
13976 XLinkPos = SearchElement.
XLinkPos;
13977 PrefDirElement = SearchElement;
14034 unsigned int TruncatePrefDirPosition = 0;
14108 throw Exception(
"Error - failed to validate extended route for preferred route");
14164 throw Exception(
"Error - failed to validate single route for preferred route");
14213 AnsiString(VLoc) +
"," + AnsiString((
short)Callon));
14215 int TrackVectorPosition;
14251 int LockedVectorNumber;
14282 PrefDirElement1.
ELink = PrefDirElement1.
Link[0];
14283 PrefDirElement1.
XLink = PrefDirElement1.
Link[1];
14286 throw Exception(
"Error, No EXNumber for PrefDirElement1 in GetNonPreferredRouteStartElement");
14292 PrefDirElement2.
ELink = PrefDirElement2.
Link[1];
14293 PrefDirElement2.
XLink = PrefDirElement2.
Link[0];
14296 throw Exception(
"Error, No EXNumber for PrefDirElement2 in GetNonPreferredRouteStartElement");
14310 if(RoutePair.first > -1)
14494 EndElement1.
ELink = EndElement1.
Link[0];
14495 EndElement1.
XLink = EndElement1.
Link[1];
14498 throw Exception(
"Error, No EXNumber for EndElement1 in GetNonPreferredRouteStartElement");
14503 EndElement2.
ELink = EndElement2.
Link[1];
14504 EndElement2.
XLink = EndElement2.
Link[0];
14507 throw Exception(
"Error, No EXNumber for EndElement2 in GetNonPreferredRouteStartElement");
14553 if(RoutePair.first > -1)
14555 if(RoutePair.second != 0)
14574 EndElement2 = BlankElement;
14653 PointsChanged =
true;
14677 PointsChanged =
true;
14697 PointsChanged =
true;
14721 PointsChanged =
true;
14735 PointsChanged =
true;
14773 AnsiString(XLinkPos) +
"," + AnsiString(RequiredPosition) +
"," + AnsiString() +
"," + AnsiString(
ReqPosRouteID.
GetInt()));
14774 int VectorCount = 0;
14777 if((CurrentTrackElement.
Link[XLinkPos] == 1) || (CurrentTrackElement.
Link[XLinkPos] == 3) || (CurrentTrackElement.
Link[XLinkPos] == 7) ||
14778 (CurrentTrackElement.
Link[XLinkPos] == 9))
14782 for(
int x = 0; x < VectorCount; x++)
14793 for(
int x = 0; x < VectorCount; x++)
14798 if(CurrentTrackElement.
Config[XLinkPos] ==
End)
14800 for(
int x = 0; x < VectorCount; x++)
14805 int NextPosition = CurrentTrackElement.
Conn[XLinkPos];
14809 int NextELinkPos = CurrentTrackElement.
ConnLinkPos[XLinkPos];
14810 SearchElement.
ELinkPos = NextELinkPos;
14823 SearchElement.
XLink = SearchElement.
Link[NextXLinkPos];
14825 SearchElement.
XLinkPos = NextXLinkPos;
14838 for(
int x = 0; x < VectorCount; x++)
14850 if(RoutePair.first > -1)
14859 for(
int x = 0; x < VectorCount; x++)
14866 if(SecondPair.first > -1)
14875 for(
int x = 0; x < VectorCount; x++)
14888 for(
int x = 0; x < VectorCount; x++)
14897 for(
int x = 0; x < VectorCount; x++)
14904 for(
int x = 0; x < VectorCount; x++)
14912 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
14916 for(
int x = 0; x < VectorCount; x++)
14928 for(
int x = 0; x < VectorCount; x++)
14955 for(
int x = 0; x < VectorCount; x++)
14964 for(
int x = 0; x < VectorCount; x++)
14974 int SearchPos1 = SearchElement.
Attribute + 1;
14976 if(SearchPos1 == 2)
14978 if(SearchPos1 == 1)
14983 SearchElement.
XLink = SearchElement.
Link[SearchPos1];
14984 SearchElement.
XLinkPos = SearchPos1;
14986 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
14990 for(
int x = 0; x < VectorCount; x++)
15013 SearchElement.
XLink = SearchElement.
Link[SearchPos2];
15014 SearchElement.
XLinkPos = SearchPos2;
15016 if((SearchElement.
XLink == 1) || (SearchElement.
XLink == 3) || (SearchElement.
XLink == 7) || (SearchElement.
XLink == 9))
15020 for(
int x = 0; x < VectorCount; x++)
15037 for(
int x = 0; x < VectorCount; x++)
15049 CurrentTrackElement = SearchElement;
15050 XLinkPos = SearchElement.
XLinkPos;
15072 throw Exception(
"Error, SearchVector empty");
15084 for(
int x = 0; x < 4; x++)
15118 throw Exception(
"Error in EntryExitNumber 3");
15174 unsigned int TruncatePrefDirPosition = 0;
15235 throw Exception(
"Failed to validate extended route for nonpreferred route");
15281 throw Exception(
"Failed to validate single route for nonpreferred route");
15301 if(!PrefDirVector.empty())
15305 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 1) || (PrefDirPtr->XLinkPos == 1)))
15310 if((PrefDirPtr->TrackType ==
Points) && ((PrefDirPtr->ELinkPos == 3) || (PrefDirPtr->XLinkPos == 3)))
15345 if(!PrefDirVector.empty())
15348 TPrefDirElement LastElement = GetFixedPrefDirElementAt(185, PrefDirSize() - 1);
15350 int ForwardLinkedRouteNumber, Attribute = 0;
15357 if(ForwardLinkedRouteNumber > -1)
15359 int NextForwardLinkedRouteNumber = -1;
15363 ForwardLinkedRouteNumber = NextForwardLinkedRouteNumber;
15373 GetFixedPrefDirElementAt(193, 0).XLinkPos, RouteNumber);
15392 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 1) || (SearchPtr->XLinkPos == 1)))
15400 if((SearchPtr->TrackType ==
Points) && ((SearchPtr->ELinkPos == 3) || (SearchPtr->XLinkPos == 3)))
15431 NextForwardLinkedRouteNumber = -1;
15432 for(
unsigned int x = 0; x < PrefDirSize(); x++)
15434 int TrainID =
Track->
TrackElementAt(100, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnElement;
15435 if(PrefDirVector.at(x).TrackType ==
Bridge)
15437 if(PrefDirVector.at(x).XLinkPos < 2)
15438 TrainID =
Track->
TrackElementAt(101, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeTrackPos01;
15440 TrainID =
Track->
TrackElementAt(102, PrefDirVector.at(x).TrackVectorPosition).TrainIDOnBridgeTrackPos23;
15447 if(PrefDirVector.at(x).TrackType ==
Buffers)
15459 if(
Track->
IsLCAtHV(42, PrefDirVector.at(x).HLoc, PrefDirVector.at(x).VLoc))
15468 if(PrefDirVector.at(x).Config[PrefDirVector.at(x).XLinkPos] ==
Signal)
15470 Attribute =
Track->
TrackElementAt(103, PrefDirVector.at(x).TrackVectorPosition).Attribute + 1;
15476 if(x == PrefDirSize() - 1)
15518 AnsiString(PrefDirVectorStartPosition));
15523 bool SkipContinuationAndBufferAttributeChange =
false;
15525 if(!PrefDirVector.empty())
15527 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr < PrefDirVector.end(); PrefDirPtr++)
15530 if(PrefDirPtr->TrackType ==
Bridge)
15532 if(PrefDirPtr->XLinkPos < 2)
15539 SkipContinuationAndBufferAttributeChange =
true;
15554 SkipContinuationAndBufferAttributeChange =
true;
15562 SkipContinuationAndBufferAttributeChange =
true;
15564 if(!SkipContinuationAndBufferAttributeChange)
15566 if(PrefDirVector.back().TrackType ==
Buffers)
15572 for(
TPrefDirVectorConstIterator PrefDirPtr = (PrefDirVector.begin() + PrefDirVectorStartPosition); PrefDirPtr >= PrefDirVector.begin(); PrefDirPtr--)
15575 if(PrefDirPtr->TrackType ==
Bridge)
15577 if(PrefDirPtr->XLinkPos < 2)
15589 if(
Track->
IsLCAtHV(20, PrefDirPtr->HLoc, PrefDirPtr->VLoc))
15598 if(PrefDirPtr->Config[PrefDirPtr->XLinkPos] ==
Signal)
15600 if((!
AllRoutes->
RouteTruncateFlag) || (PrefDirPtr != (PrefDirVector.begin() + PrefDirVectorStartPosition)) || PrefDirPtr->AutoSignals ||
15601 PrefDirPtr->ConsecSignals)
15642 "," + AnsiString((
short)ConsecSignalsRoute));
15643 bool ElementInRoute =
false;
15644 bool TrainOccupyingRoute =
false;
15650 ElementInRoute =
true;
15654 if(!ElementInRoute)
15678 TrainOccupyingRoute =
true;
15746 if(LRVIT->RouteNumber == RouteNumber)
15761 int button = Application->MessageBox(L
"Train approaching or occupying route, YES to lock route (2 minutes to release), NO to cancel",
15762 L
"Warning!", MB_YESNO | MB_ICONWARNING);
15774 bool ExistingLockedRouteModified =
false;
15787 if(LRVIT->RouteNumber == RouteNumber)
15791 ExistingLockedRouteModified =
true;
15795 if(!ExistingLockedRouteModified)
15883 AnsiString((
short)ConsecSignalsRoute));
15893 ConsecSignalsRoute);
15908 AnsiString((
short)ConsecSignalsRoute));
15918 RouteFlashElement.
HLoc = H;
15919 RouteFlashElement.
VLoc = V;
15935 int H = PrefDirPtr->HLoc;
15936 int V = PrefDirPtr->VLoc;
15998 for(
unsigned int x = 0; x < RouteFlashVector.size(); x++)
16002 Display->
PlotOutput(21, RouteFlashVector.at(x).HLoc * 16, RouteFlashVector.at(x).VLoc * 16, RouteFlashVector.at(x).OriginalGraphic);
16005 OverlayPlotted =
false;
16015 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
16017 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetFixedRouteAt");
16020 return AllRoutesVector.at(At);
16029 if((At < 0) || ((
unsigned int)At >= AllRoutesVector.size()))
16031 throw Exception(
"Out of Range Error, vector size: " + AnsiString(AllRoutesVector.size()) +
", At: " + AnsiString(At) +
" in GetModifiableRouteAt");
16034 return AllRoutesVector.at(At);
16045 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
16047 GetFixedRouteAt(62, a).PrefDirMarker(7,
RouteCall,
false, Disp);
16057 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
16059 GetFixedRouteAt(166, a).RouteImageMarker(0, Bitmap);
16077 AnsiString(VLoc) +
"," + AnsiString((
short)ConsecSignalsRoute));
16078 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
16081 RouteTruncateFlag =
true;
16083 GetModifiableRouteAt(7, a).GetRouteTruncateElement(0, HLoc, VLoc, ConsecSignalsRoute, ReturnFlag);
16084 RouteTruncateFlag =
false;
16111 AnsiString(LinkPos));
16112 if(TrackVectorPosition == -1)
16117 THVPair Route2MultiMapKeyPair;
16121 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
16124 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16134 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16136 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16139 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(64, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(88,
16140 Route2MultiMapIterator->second.second);
16141 EntryLinkPos = PrefDirElement1.
ELinkPos;
16142 ExitLinkPos = PrefDirElement1.
XLinkPos;
16143 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
16144 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
16156 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16168 Graphics::TBitmap* &EntryDirectionGraphicPtr)
16178 AnsiString(LinkPos));
16181 if(TrackVectorPosition == -1)
16186 THVPair Route2MultiMapKeyPair;
16190 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
16193 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16198 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16200 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16202 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(73, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(97,
16203 Route2MultiMapIterator->second.second);
16204 EntryLinkPos = PrefDirElement1.
ELinkPos;
16205 ExitLinkPos = PrefDirElement1.
XLinkPos;
16206 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
16207 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
16211 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(74,
16212 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
16219 return AutoSigsRoute;
16224 return NotAutoSigsRoute;
16230 if((Route2MultiMapIterator->second.second == 0) || (Route2MultiMapIterator->second.second == GetFixedRouteAt(75,
16231 Route2MultiMapIterator->second.first).PrefDirSize() - 1))
16238 return AutoSigsRoute;
16243 return NotAutoSigsRoute;
16247 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16249 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16250 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16252 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(76, ItPair.first->second.first).GetFixedPrefDirElementAt(98, ItPair.first->second.second);
16253 EntryLinkPos = PrefDirElement2.
ELinkPos;
16254 ExitLinkPos = PrefDirElement2.
XLinkPos;
16255 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
16256 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
16260 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(77, ItPair.first->second.first).PrefDirSize() - 1))
16267 return AutoSigsRoute;
16272 return NotAutoSigsRoute;
16278 if((ItPair.first->second.second == 0) || (ItPair.first->second.second == GetFixedRouteAt(78, ItPair.first->second.first).PrefDirSize() - 1))
16285 return AutoSigsRoute;
16290 return NotAutoSigsRoute;
16295 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(79, ItPair.second->second.first).GetFixedPrefDirElementAt(99, ItPair.second->second.second);
16296 EntryLinkPos = PrefDirElement3.
ELinkPos;
16297 ExitLinkPos = PrefDirElement3.
XLinkPos;
16298 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
16299 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
16303 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(80, ItPair.second->second.first).PrefDirSize() - 1))
16310 return AutoSigsRoute;
16315 return NotAutoSigsRoute;
16321 if((ItPair.second->second.second == 0) || (ItPair.second->second.second == GetFixedRouteAt(81, ItPair.second->second.first).PrefDirSize() - 1))
16328 return AutoSigsRoute;
16333 return NotAutoSigsRoute;
16349 AnsiString(LinkPos));
16350 if(TrackVectorPosition == -1)
16356 THVPair Route2MultiMapKeyPair;
16360 int EntryLink, EntryLinkPos, ExitLink, ExitLinkPos;
16363 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16369 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16371 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16373 const TPrefDirElement &PrefDirElement1 = GetFixedRouteAt(82, Route2MultiMapIterator->second.first).GetFixedPrefDirElementAt(100,
16374 Route2MultiMapIterator->second.second);
16375 EntryLinkPos = PrefDirElement1.
ELinkPos;
16376 ExitLinkPos = PrefDirElement1.
XLinkPos;
16377 EntryLink = PrefDirElement1.
Link[EntryLinkPos];
16378 ExitLink = PrefDirElement1.
Link[ExitLinkPos];
16381 RouteNumber = Route2MultiMapIterator->second.first;
16385 return AutoSigsRoute;
16390 return NotAutoSigsRoute;
16395 RouteNumber = Route2MultiMapIterator->second.first;
16399 return AutoSigsRoute;
16404 return NotAutoSigsRoute;
16408 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16410 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16411 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16413 const TPrefDirElement &PrefDirElement2 = GetFixedRouteAt(83, ItPair.first->second.first).GetFixedPrefDirElementAt(101, ItPair.first->second.second);
16414 EntryLinkPos = PrefDirElement2.
ELinkPos;
16415 ExitLinkPos = PrefDirElement2.
XLinkPos;
16416 EntryLink = PrefDirElement2.
Link[EntryLinkPos];
16417 ExitLink = PrefDirElement2.
Link[ExitLinkPos];
16420 RouteNumber = ItPair.first->second.first;
16424 return AutoSigsRoute;
16429 return NotAutoSigsRoute;
16434 RouteNumber = ItPair.first->second.first;
16438 return AutoSigsRoute;
16443 return NotAutoSigsRoute;
16448 const TPrefDirElement &PrefDirElement3 = GetFixedRouteAt(84, ItPair.second->second.first).GetFixedPrefDirElementAt(102, ItPair.second->second.second);
16449 EntryLinkPos = PrefDirElement3.
ELinkPos;
16450 ExitLinkPos = PrefDirElement3.
XLinkPos;
16451 EntryLink = PrefDirElement3.
Link[EntryLinkPos];
16452 ExitLink = PrefDirElement3.
Link[ExitLinkPos];
16455 RouteNumber = ItPair.second->second.first;
16459 return AutoSigsRoute;
16464 return NotAutoSigsRoute;
16469 RouteNumber = ItPair.second->second.first;
16473 return AutoSigsRoute;
16478 return NotAutoSigsRoute;
16500 EmptyRoute.
RouteID = NextRouteID;
16503 AllRoutesVector.push_back(EmptyRoute);
16504 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
16529 AllRoutesVector.push_back(EmptyRoute);
16530 for(
unsigned int x = 0; x < Route->
PrefDirSize(); x++)
16553 THVPair Route2MultiMapKeyPair;
16562 LockedRouteTruncateTrackVectorPosition = 0;
16563 LockedRouteLastTrackVectorPosition = 0;
16564 LockedRouteLastXLinkPos = 0;
16565 LockedRouteLockStartTime = TDateTime(0);
16566 if(!LockedRouteVector.empty())
16570 if(LRVIT->RouteNumber == RouteNumber)
16572 LockedRouteTruncateTrackVectorPosition = LRVIT->TruncateTrackVectorPosition;
16573 LockedRouteLastTrackVectorPosition = LRVIT->LastTrackVectorPosition;
16574 LockedRouteLastXLinkPos = LRVIT->LastXLinkPos;
16575 LockedRouteLockStartTime = LRVIT->LockStartTime;
16576 LockedRouteFoundDuringRouteBuilding =
true;
16577 LockedRouteVector.erase(LRVIT);
16603 AnsiString(VLoc) +
"," + AnsiString(ELink));
16606 ReturnPair.first = -1;
16607 ReturnPair.second = 0;
16608 THVPair Route2MultiMapKeyPair;
16610 Route2MultiMapKeyPair.first = HLoc;
16611 Route2MultiMapKeyPair.second = VLoc;
16614 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
16615 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16617 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16618 Route2MultiMapIterator = ItPair.first;
16620 if(ItPair.first == ItPair.second)
16622 throw Exception(
"Failed to find Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc);
16625 if(GetFixedRouteAt(111, ItPair.first->second.first).GetFixedPrefDirElementAt(132, ItPair.first->second.second).GetELink() == ELink)
16627 ReturnPair.first = ItPair.first->second.first;
16628 ReturnPair.second = ItPair.first->second.second;
16629 Route2MultiMapIterator = ItPair.first;
16634 if(ItPair.first == ItPair.second)
16636 throw Exception(
"Found Route2MultiMap element at HLoc = " + (AnsiString)HLoc +
" VLoc = " + (AnsiString)VLoc +
" but failed to find required element");
16638 if(GetFixedRouteAt(112, ItPair.first->second.first).GetFixedPrefDirElementAt(133, ItPair.first->second.second).GetELink() == ELink)
16640 ReturnPair.first = ItPair.first->second.first;
16641 ReturnPair.second = ItPair.first->second.second;
16642 Route2MultiMapIterator = ItPair.first;
16662 AnsiString(VLoc) +
"," + AnsiString(ELink));
16663 THVPair Route2MultiMapKeyPair;
16665 Route2MultiMapKeyPair.first = HLoc;
16666 Route2MultiMapKeyPair.second = VLoc;
16667 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItPair;
16669 ItPair = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16671 if(ItPair.first == ItPair.second)
16678 if(GetFixedRouteAt(205, ItPair.first->second.first).GetFixedPrefDirElementAt(241, ItPair.first->second.second).GetELink() == ELink)
16680 RouteNumber = ItPair.first->second.first;
16687 if(ItPair.first == ItPair.second)
16694 if(GetFixedRouteAt(206, ItPair.first->second.first).GetFixedPrefDirElementAt(242, ItPair.first->second.second).GetELink() == ELink)
16696 RouteNumber = ItPair.first->second.first;
16717 "," + AnsiString(ELinkIn) +
"," + AnsiString(RouteNumber) +
"," + AnsiString(RouteElementNumber));
16718 THVPair Route2MultiMapKeyPair;
16720 Route2MultiMapKeyPair.first = HLoc;
16721 Route2MultiMapKeyPair.second = VLoc;
16724 Route2MultiMapEntry.first = Route2MultiMapKeyPair;
16727 RouteElementPair.first = RouteNumber;
16728 RouteElementPair.second = RouteElementNumber;
16729 Route2MultiMapEntry.second = RouteElementPair;
16731 if(Route2MultiMap.find(Route2MultiMapKeyPair) != Route2MultiMap.end())
16734 if(GetFixedRouteAt(113, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(134,
16735 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).GetELink() != ELinkIn)
16738 if(GetFixedRouteAt(114, Route2MultiMap.find(Route2MultiMapKeyPair)->second.first).GetFixedPrefDirElementAt(135,
16739 Route2MultiMap.find(Route2MultiMapKeyPair)->second.second).TrackType !=
Bridge)
16741 throw Exception(
"Error, bridge expected in Route2MultiMapInsert but not, at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
16743 Route2MultiMap.insert(Route2MultiMapEntry);
16748 throw Exception(
"Error, route map entry found in Route2MultiMapInsert at HLoc=" + AnsiString(HLoc) +
" VLoc=" + AnsiString(VLoc));
16752 Route2MultiMap.insert(Route2MultiMapEntry);
16769 TempPair.first = -1;
16770 TempPair.second = 0;
16771 SecondPair = TempPair;
16773 std::pair<TRoute2MultiMapIterator, TRoute2MultiMapIterator>ItRange;
16774 THVPair Route2MultiMapKeyPair;
16776 Route2MultiMapKeyPair.first = HLoc;
16777 Route2MultiMapKeyPair.second = VLoc;
16778 if(Route2MultiMap.count(Route2MultiMapKeyPair) == 0)
16783 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 1)
16785 Route2MultiMapIterator = Route2MultiMap.find(Route2MultiMapKeyPair);
16787 return Route2MultiMapIterator->second;
16789 else if(Route2MultiMap.count(Route2MultiMapKeyPair) == 2)
16791 ItRange = Route2MultiMap.equal_range(Route2MultiMapKeyPair);
16792 TempPair = ItRange.first->second;
16793 SecondPair = (--ItRange.second)->second;
16816 TRouteElementPair RouteElementPair = GetRouteElementDataFromRoute2MultiMap(8, CheckElement.
HLoc, CheckElement.
VLoc, SecondPair);
16817 if(RouteElementPair.first == -1)
16820 throw Exception(
"CheckMapAndRoutes Error - failed to find HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" + (AnsiString)CheckElement.
VLoc +
16821 " in Route2MultiMap, Caller=" + (AnsiString)Caller);
16823 if((RouteElementPair.first != (
int)a) && (SecondPair.first != (
int)a))
16826 throw Exception(
"CheckMapAndRoutes Error - RouteNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
16827 (AnsiString)CheckElement.
VLoc +
" Map value=" + (AnsiString)RouteElementPair.first +
" Route value=" + (AnsiString)a +
" Caller=" +
16828 (AnsiString)Caller);
16830 if(((RouteElementPair.first != (
int)a) || (RouteElementPair.second != b)) && ((SecondPair.first != (
int)a) || (SecondPair.second != b)))
16833 throw Exception(
"CheckMapAndRoutes Error - PrefDirVectorNumber failed at HLoc=" + (AnsiString)CheckElement.
HLoc +
" VLoc=" +
16834 (AnsiString)CheckElement.
VLoc +
" 1st Map value RouteNum/ElementNum =" + (AnsiString)RouteElementPair.first +
"/" +
16835 (AnsiString)RouteElementPair.second +
" 2nd Map value =" + (AnsiString)SecondPair.first +
"/" + (AnsiString)SecondPair.second +
16836 " Route value=" + (AnsiString)a +
"/" + (AnsiString)b +
" Caller=" + (AnsiString)Caller);
16840 unsigned int SizeVal = 0;
16843 for(
unsigned int a = 0; a < AllRoutesSize(); a++)
16845 SizeVal += GetFixedRouteAt(117, a).PrefDirSize();
16847 if(SizeVal != Route2MultiMap.size())
16849 throw Exception(
"CheckMapAndRoutes Error - Map Size=" + (AnsiString)Route2MultiMap.size() +
" RouteSize=" + (AnsiString)SizeVal +
" Caller=" +
16850 (AnsiString)Caller);
16866 if(!Route2MultiMap.empty())
16868 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
16870 if(Route2MultiMapIterator->second.first > RouteNumber)
16871 Route2MultiMapIterator->second.first--;
16887 AnsiString(RouteNumber) +
"," + AnsiString(ErasedElementNumber));
16888 if(!Route2MultiMap.empty())
16890 for(
TRoute2MultiMapIterator Route2MultiMapIterator = Route2MultiMap.begin(); Route2MultiMapIterator != Route2MultiMap.end(); Route2MultiMapIterator++)
16892 if((Route2MultiMapIterator->second.first == RouteNumber) && (Route2MultiMapIterator->second.second > ErasedElementNumber))
16893 Route2MultiMapIterator->second.second--;
16911 AnsiString(ELink));
16915 RequiredRoutePair = FindRoutePairFromRoute2MultiMap(0, HLoc, VLoc, ELink, Route2MultiMapIterator);
16916 if(RequiredRoutePair.first == -1)
16918 throw Exception(
"Failed to find route element in RemoveRouteElement");
16920 Route2MultiMap.erase(Route2MultiMapIterator);
16921 DecrementRouteElementNumbersInRoute2MultiMap(0, RequiredRoutePair.first, RequiredRoutePair.second);
16924 TPrefDirElement LockedRouteElement, PrefDirElement = GetFixedRouteAt(118, RequiredRoutePair.first).GetFixedPrefDirElementAt(137, RequiredRoutePair.second);
16946 GetModifiableRouteAt(8, RequiredRoutePair.first).EraseRouteElementAt(&(GetModifiableRouteAt(9, RequiredRoutePair.first).GetModifiablePrefDirElementAt(1,
16947 RequiredRoutePair.second)));
16958 if(AutoSigVectorIT->RouteNumber == RequiredRoutePair.first)
16967 if(GetModifiableRouteAt(10, RequiredRoutePair.first).PrefDirSize() == 0)
16969 TrainController->
LogEvent(
"RouteRemoved," + AnsiString(GetFixedRouteAt(189, RequiredRoutePair.first).RouteID));
16970 AllRoutesVector.erase(AllRoutesVector.begin() + RequiredRoutePair.first);
16971 DecrementRouteNumbersInRoute2MultiMap(0, RequiredRoutePair.first);
16983 if(!LockedRouteVector.empty())
16987 if(LRVIT->RouteNumber > RequiredRoutePair.first)
16989 LRVIT->RouteNumber--;
17000 if(AutoSigVectorIT->RouteNumber > RequiredRoutePair.first)
17001 AutoSigVectorIT->RouteNumber--;
17005 CheckMapAndRoutes(7);
17019 AnsiString(ELink) +
"," + AnsiString(RouteNumber) +
"," + RouteElement.
LogPrefDir());
17020 GetModifiableRouteAt(11, RouteNumber).StoreRouteElementInPrefDirVector(RouteElement);
17021 Route2MultiMapInsert(0, HLoc, VLoc, ELink, RouteNumber, GetModifiableRouteAt(12, RouteNumber).
PrefDirSize() - 1);
17037 "," + AnsiString(XLinkPos));
17041 RouteElementPair = GetRouteElementDataFromRoute2MultiMap(9, TE.
HLoc, TE.
VLoc, SecondPair);
17042 if(RouteElementPair.first == -1)
17044 throw Exception(
"Error, failed to find element in SetTrailingSignalsOnAutoSigsRoute - 1");
17046 TPrefDirElement RouteElement = GetFixedRouteAt(119, RouteElementPair.first).GetFixedPrefDirElementAt(138, RouteElementPair.second);
17048 RequiredPair = RouteElementPair;
17049 if(RouteElement.
XLinkPos != XLinkPos)
17051 if(SecondPair.first != -1)
17053 RouteElement = GetFixedRouteAt(120, SecondPair.first).GetFixedPrefDirElementAt(139, SecondPair.second);
17054 RequiredPair = SecondPair;
17055 if(RouteElement.
XLinkPos != XLinkPos)
17057 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 2");
17062 throw Exception(
"Failed to find element in route in SetTrailingSignalsOnAutoSigsRoute - 3");
17067 SetAllRearwardsSignals(5, 0, RequiredPair.first, RequiredPair.second);
17087 AnsiString(AccessNumber));
17089 int Attribute = AccessNumber + 1;
17091 int x = GetFixedRouteAt(121, RouteNumber).PrefDirSize() - 1;
17095 throw Exception(
"Error - route not AutoSignals in SetTrailingSignalsOnContinuationRoute");
17099 throw Exception(
"Error - end element not continuation in SetTrailingSignalsOnContinuationRoute");
17102 x).XLinkPos] !=
End)
17104 throw Exception(
"Error - end element a continuation in SetTrailingSignalsOnContinuationRoute but End not facing right way");
17107 SetAllRearwardsSignals(6, Attribute, RouteNumber, GetFixedRouteAt(126, RouteNumber).
PrefDirSize() - 1);
17149 AnsiString(RouteNumber) +
"," + AnsiString(RouteStartPosition));
17150 TPrefDirElement FirstElement = GetFixedRouteAt(127, RouteNumber).GetFixedPrefDirElementAt(144, 0);
17151 int RearwardLinkedRouteNumber;
17175 int TrainID, TrainPosition, BehindTrainPosition;
17176 bool FoundTrain =
false, BehindTrain =
false;
17177 for(
int x = RouteStartPosition; x >= 0; x--)
17179 TPrefDirElement PrefDirElement = GetFixedRouteAt(132, RouteNumber).GetFixedPrefDirElementAt(146, x);
17198 if(FoundTrain && (TrainPosition > 1))
17200 for(
int x = TrainPosition; x >= 0; x--)
17205 TPrefDirElement PrefDirElement = GetFixedRouteAt(133, RouteNumber).GetFixedPrefDirElementAt(147, x);
17219 BehindTrain =
true;
17220 BehindTrainPosition = x;
17227 SetAllRearwardsSignals(7, 0, RouteNumber, BehindTrainPosition);
17244 AnsiString(RouteTruncatePosition));
17245 int SignalCount = 0, TrainID, RearwardLinkedRouteNumber, StartPosition = RouteTruncatePosition;
17246 TOneRoute CurrentRoute = GetFixedRouteAt(134, RouteNumber);
17249 bool ExamineRoute =
true;
17251 while(ExamineRoute)
17253 for(
int x = StartPosition; x >= 0; x--)
17290 if(SignalCount >= 3)
17309 CurrentRoute = GetFixedRouteAt(135, RearwardLinkedRouteNumber);
17310 ExamineRoute =
true;
17311 StartPosition = GetFixedRouteAt(136, RearwardLinkedRouteNumber).PrefDirSize() - 1;
17342 ExamineRoute =
false;
17357 AnsiString(TrackVectorPosition) +
"," + AnsiString(XLinkPos));
17360 PrefDirElement = InternalPrefDirElement;
17361 if(LockedRouteVector.empty())
17368 bool InLockedRoute =
false;
17372 if(TrackIsInARoute(14, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos))
17375 InLockedRoute =
true;
17385 int RouteNumber, VectorCount = 0;
17390 RouteType = GetRouteTypeAndNumber(8, LRVIT->LastTrackVectorPosition, LRVIT->LastXLinkPos, RouteNumber);
17391 if(RouteType == NoRoute)
17395 GetFixedRouteAt(140, RouteNumber).
PrefDirSize() - 1).XLinkPos != LRVIT->LastXLinkPos))
17398 (
"Error, last element in locked route doesn't correspond with last element in associated route in IsElementInLockedRouteGetPrefDirElement");
17400 for(
int x = GetFixedRouteAt(141, RouteNumber).
PrefDirSize() - 1; x >= 0; x--)
17402 InternalPrefDirElement = GetFixedRouteAt(142, RouteNumber).GetFixedPrefDirElementAt(152, x);
17403 if(InternalPrefDirElement.
TrackVectorPosition != (
int)LRVIT->TruncateTrackVectorPosition)
17407 PrefDirElement = InternalPrefDirElement;
17408 LockedVectorNumber = VectorCount;
17413 else if(InternalPrefDirElement.
TrackVectorPosition == (
int)LRVIT->TruncateTrackVectorPosition)
17417 PrefDirElement = InternalPrefDirElement;
17418 LockedVectorNumber = VectorCount;
17437 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17439 if(GetFixedRouteAt(157, x).RouteID ==
RouteID.GetInt())
17445 throw Exception(
"Error, failed to find RouteID in GetRouteVectorNumber for ID: " + AnsiString(
RouteID.GetInt()));
17455 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17457 if(GetFixedRouteAt(45, x).RouteID ==
RouteID.GetInt())
17472 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17474 if(GetFixedRouteAt(163, x).RouteID ==
RouteID.GetInt())
17477 return GetFixedRouteAt(159, x);
17480 throw Exception(
"Error, failed to find RouteID in GetFixedRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
17488 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17490 if(GetFixedRouteAt(164, x).RouteID ==
RouteID.GetInt())
17493 return GetModifiableRouteAt(15, x);
17496 throw Exception(
"Error, failed to find RouteID in GetModifiableRouteAtIDNumber for ID: " + AnsiString(
RouteID.GetInt()));
17506 for(
unsigned int x = 0; x < AllRoutesSize(); x++)
17508 TOneRoute OneRoute = GetFixedRouteAt(165, x);
17520 int NumberOfRoutes;
17524 for(
int x = 0; x < NumberOfRoutes; x++)
17531 StoreOneRouteAfterSessionLoad(0, &OneRoute);
17549 if((NumberOfRoutes < 0) || (NumberOfRoutes > 5000))
17556 if((NextID < 0) || (NextID > 1000000))
17561 for(
int x = 0; x < NumberOfRoutes; x++)
17585 AnsiString(StartPosition));
17586 if(EndPosition == StartPosition)
17592 int TVPos = EndPosition;
17593 int LkPos = EndXLinkPos;
17595 while(TrackIsInARoute(15, TVPos, LkPos))
17622 if(GetRouteTypeAndNumber(36, NewTVPos, NewLkPos, RouteNumber) == NoRoute)
17631 if((NewLkPos == 0) || (NewLkPos == 2))
17643 if(TVPos == StartPosition)
17675 AnsiString(VLoc) +
"," + AnsiString(DiagonalLinkNumber));
17680 if(FirstPair.first > -1)
17683 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17688 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17694 if(SecondPair.first > -1)
17697 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17702 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17709 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(0, HLoc - 1, VLoc, 3, TrainID)) || ((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(1, HLoc - 1, VLoc,
17717 if(FirstPair.first > -1)
17720 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17725 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17731 if(SecondPair.first > -1)
17734 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17739 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17746 if(((DiagonalLinkNumber == 1) &&
Track->
TrainOnLink(2, HLoc, VLoc - 1, 7, TrainID)) || ((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(3, HLoc, VLoc - 1,
17754 if(FirstPair.first > -1)
17757 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17762 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17768 if(SecondPair.first > -1)
17771 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17776 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17783 if(((DiagonalLinkNumber == 3) &&
Track->
TrainOnLink(4, HLoc + 1, VLoc, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(5, HLoc + 1, VLoc,
17791 if(FirstPair.first > -1)
17794 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17799 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17805 if(SecondPair.first > -1)
17808 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17813 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17820 if(((DiagonalLinkNumber == 7) &&
Track->
TrainOnLink(6, HLoc, VLoc + 1, 1, TrainID)) || ((DiagonalLinkNumber == 9) &&
Track->
TrainOnLink(7, HLoc, VLoc + 1,
17845 "," + AnsiString(DiagonalLinkNumber));
17850 if(FirstPair.first > -1)
17853 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17858 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17864 if(SecondPair.first > -1)
17867 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17872 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17880 if(FirstPair.first > -1)
17883 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17888 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17894 if(SecondPair.first > -1)
17897 if((DiagonalLinkNumber == 1) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17902 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 9) || (TempPrefDirElement.
XLink == 9)))
17910 if(FirstPair.first > -1)
17913 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17918 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17924 if(SecondPair.first > -1)
17927 if((DiagonalLinkNumber == 3) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17932 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 7) || (TempPrefDirElement.
XLink == 7)))
17940 if(FirstPair.first > -1)
17943 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17948 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))
17954 if(SecondPair.first > -1)
17957 if((DiagonalLinkNumber == 7) && ((TempPrefDirElement.
ELink == 1) || (TempPrefDirElement.
XLink == 1)))
17962 if((DiagonalLinkNumber == 9) && ((TempPrefDirElement.
ELink == 3) || (TempPrefDirElement.
XLink == 3)))